Skip to content

Commit 8f98134

Browse files
author
Namrata Madan
committed
fix: make RemoteExecutor context manager non-blocking on pending futures
1 parent 20cffd6 commit 8f98134

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sagemaker/remote_function/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def map(self, func, *iterables):
731731
futures = map(self.submit, itertools.repeat(func), *iterables)
732732
return [future.result() for future in futures]
733733

734-
def shutdown(self):
734+
def shutdown(self, wait=True):
735735
"""Prevent more function executions to be submitted to this executor."""
736736
with self._state_condition:
737737
self._shutdown = True
@@ -742,15 +742,15 @@ def shutdown(self):
742742
self._state_condition.notify_all()
743743

744744
if self._workers is not None:
745-
self._workers.shutdown(wait=True)
745+
self._workers.shutdown(wait)
746746

747747
def __enter__(self):
748748
"""Create an executor instance and return it"""
749749
return self
750750

751751
def __exit__(self, exc_type, exc_val, exc_tb):
752752
"""Make sure the executor instance is shutdown."""
753-
self.shutdown()
753+
self.shutdown(wait=False)
754754
return False
755755

756756
@staticmethod

0 commit comments

Comments
 (0)