diff --git a/pympipool/shared/executorbase.py b/pympipool/shared/executorbase.py index 9e75f31a..8e64096a 100644 --- a/pympipool/shared/executorbase.py +++ b/pympipool/shared/executorbase.py @@ -55,10 +55,17 @@ 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): + try: + self.shutdown(wait=True) + except (AttributeError, RuntimeError): + pass + def _set_init_function(self, init_function): if init_function is not None: self._future_queue.put(