forked from platypush/platypush
Put the join back on CommandStream.__exit__
.
We want to give the process a bit of slack between the terminate and the close, or we'll be guaranteed to get race conditions upon close.
This commit is contained in:
parent
6ee064cb89
commit
f1acff00e9
1 changed files with 8 additions and 3 deletions
|
@ -34,7 +34,7 @@ class CommandStream(ControllableProcess):
|
||||||
super().__init__(name='platypush:cmd:stream')
|
super().__init__(name='platypush:cmd:stream')
|
||||||
self.path = os.path.abspath(os.path.expanduser(path or self._default_sock_path))
|
self.path = os.path.abspath(os.path.expanduser(path or self._default_sock_path))
|
||||||
self._sock: Optional[socket.socket] = None
|
self._sock: Optional[socket.socket] = None
|
||||||
self._cmd_queue: Queue["Command"] = Queue()
|
self._cmd_queue = Queue()
|
||||||
self._close_lock = RLock()
|
self._close_lock = RLock()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
@ -71,16 +71,21 @@ class CommandStream(ControllableProcess):
|
||||||
def __exit__(self, *_, **__):
|
def __exit__(self, *_, **__):
|
||||||
with self._close_lock:
|
with self._close_lock:
|
||||||
self.terminate()
|
self.terminate()
|
||||||
|
self.join(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.close()
|
self.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning(str(e))
|
self.logger.warning(
|
||||||
|
'%s on command stream close: %s', type(e).__name__, str(e)
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.kill()
|
self.kill()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning(str(e))
|
self.logger.debug(
|
||||||
|
'%s on command stream kill: %s', type(e).__name__, str(e)
|
||||||
|
)
|
||||||
|
|
||||||
def _serve(self, sock: socket.socket):
|
def _serve(self, sock: socket.socket):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue