X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b02fc7b2227e923beb4d47daee7949c94b90da5f..cf0c4c381a2b34130f072096038a430e3c6bbe55:/services/nodemanager/arvnodeman/baseactor.py diff --git a/services/nodemanager/arvnodeman/baseactor.py b/services/nodemanager/arvnodeman/baseactor.py index 0142db2dc3..bdfe5d45a7 100644 --- a/services/nodemanager/arvnodeman/baseactor.py +++ b/services/nodemanager/arvnodeman/baseactor.py @@ -14,6 +14,8 @@ import traceback import pykka +from .status import tracker + class _TellCallableProxy(object): """Internal helper class for proxying callables.""" @@ -82,17 +84,21 @@ class BaseNodeManagerActor(pykka.ThreadingActor): def __init__(self, *args, **kwargs): super(pykka.ThreadingActor, self).__init__(*args, **kwargs) self.actor_ref = TellableActorRef(self) + self._killfunc = kwargs.get("killfunc", os.kill) def on_failure(self, exception_type, exception_value, tb): lg = getattr(self, "_logger", logging) if (exception_type in (threading.ThreadError, MemoryError) or exception_type is OSError and exception_value.errno == errno.ENOMEM): lg.critical("Unhandled exception is a fatal error, killing Node Manager") - os.kill(os.getpid(), signal.SIGKILL) + self._killfunc(os.getpid(), signal.SIGKILL) + tracker.counter_add('actor_exceptions') def ping(self): return True + def get_thread(self): + return threading.current_thread() class WatchdogActor(pykka.ThreadingActor): def __init__(self, timeout, *args, **kwargs):