Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataPipe] Cancel future object and always run callback in FullSync during shutdown #1171

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions torchdata/datapipes/iter/util/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def _done_callback_fn(self, index: int, f: Future):
if f.exception():
with self._lock:
self._end_flag = True
if self.callback_fn is not None and not self._is_shutdown:
# Doesn't invoke `callback_fn` if `shutdown` is caleld
self._executor.submit(self.callback_fn, Expected(index, f.exception()))
if self.callback_fn is not None:
# Invoke `callback_fn` in order to set `FullSyncDP._done_callback` to `True`
self.callback_fn(Expected(index, f.exception()))

def return_next(self):
if self._futures:
Expand All @@ -118,6 +118,8 @@ def return_next(self):
def shutdown(self):
self._paused = False
self._is_shutdown = True
while self._futures:
self._futures.popleft().cancel()
self._executor.shutdown(wait=True)

def pause(self):
Expand Down