Skip to content

Commit

Permalink
fixup! Implement safer agent shutdown/kill process
Browse files Browse the repository at this point in the history
  • Loading branch information
Peque committed Apr 9, 2018
1 parent d798ed0 commit cda9b0d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions osbrain/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ class Agent():
_async_req_handler : dict
Stores the handler for every asynchronous request sockets (used in
communication channels).
_kill_now : bool
During shutdown, this attribute is set for the agent to be killed.
_die_now : bool
During shutdown, this attribute is set for the agent to die.
_DEBUG : bool
Whether to print debug level messages.
_pending_requests : dict
Expand Down Expand Up @@ -252,7 +252,7 @@ def __init__(self, name='', host=None, serializer=None, transport=None,
self._timer = {}
self._poll_timeout = 1000
self._keep_alive = True
self._kill_now = False
self._die_now = False
self._running = False
self._DEBUG = False

Expand Down Expand Up @@ -1208,7 +1208,7 @@ def _loop(self):
if self._iterate():
break
except zmq.error.ContextTerminated:
self._kill_now = True
self._die_now = True
break

def _iterate(self):
Expand Down Expand Up @@ -1685,7 +1685,7 @@ def run(self):
self.log_error(msg)
raise
self._running = False
if self._kill_now:
if self._die_now:
self._die(linger=None)

def shutdown(self):
Expand All @@ -1696,7 +1696,7 @@ def shutdown(self):
"""
self.log_info('Stopping...')
self._keep_alive = False
self._kill_now = True
self._die_now = True

def kill(self):
"""
Expand Down

0 comments on commit cda9b0d

Please sign in to comment.