Skip to content

Commit

Permalink
Update shutdown() function
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Oct 27, 2024
1 parent 4ed66db commit 31e082c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
9 changes: 5 additions & 4 deletions executorlib/base/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ def shutdown(self, wait: bool = True, *, cancel_futures: bool = False):
"""
if cancel_futures:
cancel_items_in_queue(que=self._future_queue)
self._future_queue.put({"shutdown": True, "wait": wait})
if wait and self._process is not None:
self._process.join()
self._future_queue.join()
if self._process is not None:
self._future_queue.put({"shutdown": True, "wait": wait})
if wait:
self._process.join()
self._future_queue.join()
self._process = None
self._future_queue = None

Expand Down
24 changes: 0 additions & 24 deletions executorlib/interactive/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,6 @@ def submit(self, fn: callable, *args, resource_dict: dict = {}, **kwargs):
)
return f

def shutdown(self, wait: bool = True, *, cancel_futures: bool = False):
"""Clean-up the resources associated with the Executor.
It is safe to call this method several times. Otherwise, no other
methods can be called after this one.
Args:
wait: If True then shutdown will not return until all running
futures have finished executing and the resources used by the
parallel_executors have been reclaimed.
cancel_futures: If True then shutdown will cancel all pending
futures. Futures that are completed or running will not be
cancelled.
"""
if cancel_futures:
cancel_items_in_queue(que=self._future_queue)
if self._process is not None:
self._future_queue.put({"shutdown": True, "wait": wait})
if wait:
self._process.join()
self._future_queue.join()
self._process = None
self._future_queue = None


class InteractiveExecutor(ExecutorBroker):
"""
Expand Down

0 comments on commit 31e082c

Please sign in to comment.