Skip to content

Commit

Permalink
Add __del__() for Executors
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Nov 7, 2023
1 parent f9eb44e commit 1eff542
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pympipool/shared/executorbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ def shutdown(self, wait=True, *, cancel_futures=False):
self._future_queue.put({"shutdown": True, "wait": wait})
self._process.join()
self._future_queue.join()
self._process = None

def __len__(self):
return self._future_queue.qsize()

def __del__(self):
if self._process is not None:
self.shutdown(wait=True)

def _set_init_function(self, init_function):
if init_function is not None:
self._future_queue.put(
Expand Down

0 comments on commit 1eff542

Please sign in to comment.