Skip to content

Commit

Permalink
Improved close out resilience around lock release and timing... done …
Browse files Browse the repository at this point in the history
…wrong prevents acquire of lock to close on shutdown. See test RPYC_BIND_THREADS=true taskset -c 0 pyenv exec python -m unittest discover -v -k test_race -k test_refcount -k test_affinity -k test_deploy
  • Loading branch information
comrumino committed Mar 19, 2023
1 parent e82a0cc commit 5f41958
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rpyc/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,16 @@ def _cleanup(self, _anyway=True): # IO
# self._config.clear()
del self._HANDLERS
if self._bind_threads:
self._thread_pool_executor.shutdown(wait=False) # TODO where?
self._thread_pool_executor.shutdown(wait=True) # TODO where?
if _anyway:
try:
self._recvlock.release()
except Exception:
pass
try:
self._sendlock.release()
except Exception:
pass

def close(self): # IO
"""closes the connection, releasing all held resources"""
Expand All @@ -222,8 +231,9 @@ def close(self): # IO
self._closed = True
if self._config.get("before_closed"):
self._config["before_closed"](self.root)
# TODO: define invariants/expectations around close sequence and timing
self.sync_request(consts.HANDLE_CLOSE)
except EOFError:
except (EOFError, TimeoutError):
pass
except Exception:
if not self._config["close_catchall"]:
Expand Down

0 comments on commit 5f41958

Please sign in to comment.