X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0561bd0c3c07257fd58ded6c7cfa5feeae97af57..9fdfd5c5b229ea42193710f891e953b452bd90e7:/services/nodemanager/arvnodeman/baseactor.py diff --git a/services/nodemanager/arvnodeman/baseactor.py b/services/nodemanager/arvnodeman/baseactor.py index 988b83c142..565db6601f 100644 --- a/services/nodemanager/arvnodeman/baseactor.py +++ b/services/nodemanager/arvnodeman/baseactor.py @@ -82,17 +82,20 @@ 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) def ping(self): return True + def get_thread(self): + return threading.current_thread() class WatchdogActor(pykka.ThreadingActor): def __init__(self, timeout, *args, **kwargs): @@ -101,12 +104,13 @@ class WatchdogActor(pykka.ThreadingActor): self.actors = [a.proxy() for a in args] self.actor_ref = TellableActorRef(self) self._later = self.actor_ref.tell_proxy() + self._killfunc = kwargs.get("killfunc", os.kill) def kill_self(self, e, act): lg = getattr(self, "_logger", logging) lg.critical("Watchdog exception", exc_info=e) lg.critical("Actor %s watchdog ping time out, killing Node Manager", act) - os.kill(os.getpid(), signal.SIGKILL) + self._killfunc(os.getpid(), signal.SIGKILL) def on_start(self): self._later.run()