Skip to content

Commit

Permalink
Fix hivemind.p2p destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
borzunov committed Apr 26, 2023
1 parent c69468d commit 8d84895
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions hivemind/p2p/p2p_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,9 @@ def _terminate(self) -> None:

self._alive = False
if self._child is not None and self._child.returncode is None:
self._child.terminate()
logger.debug(f"Terminated p2pd with id = {self.peer_id}")
with suppress(ProcessLookupError):
self._child.terminate()
logger.debug(f"Terminated p2pd with id = {self.peer_id}")

with suppress(FileNotFoundError):
os.remove(self._daemon_listen_maddr["unix"])
Expand Down
3 changes: 2 additions & 1 deletion hivemind/p2p/p2p_daemon_bindings/p2pclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ async def create(
return client

def close(self) -> None:
self.control.close()
if self.control is not None:
self.control.close()

def __del__(self):
self.close()
Expand Down

0 comments on commit 8d84895

Please sign in to comment.