Skip to content

Commit

Permalink
Simplify curvezmq ctx destructor (#3050)
Browse files Browse the repository at this point in the history
The underlying `zmq.Context` object has its own `__del__` method, which
calls `self.destroy()`, so we only need to close the auth thread.
  • Loading branch information
rjmello authored Feb 5, 2024
1 parent 262e338 commit 6ff0b7b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions parsl/curvezmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ def __init__(self, cert_dir: Optional[Union[str, os.PathLike]]) -> None:
self.cert_dir = cert_dir
self._ctx = zmq.Context()

def __del__(self):
self.destroy()

@property
def encrypted(self):
"""Indicates whether encryption is enabled.
Expand Down Expand Up @@ -136,6 +133,12 @@ def __init__(self, cert_dir: Optional[Union[str, os.PathLike]]) -> None:
if self.encrypted:
self.auth_thread = self._start_auth_thread()

def __del__(self):
# Avoid issues in which the auth_thread attr was
# previously deleted
if getattr(self, "auth_thread", None):
self.auth_thread.stop()

def _start_auth_thread(self) -> ThreadAuthenticator:
auth_thread = ThreadAuthenticator(self._ctx)
auth_thread.start()
Expand Down

0 comments on commit 6ff0b7b

Please sign in to comment.