Skip to content

Commit

Permalink
Handle AsyncTaskGroupClosedError (#6664)
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait authored Jul 4, 2022
1 parent 0ecc373 commit c992f80
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion distributed/nanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from distributed.comm import get_address_host
from distributed.comm.addressing import address_from_user_args
from distributed.core import (
AsyncTaskGroupClosedError,
CommClosedError,
RPCClosed,
Status,
Expand Down Expand Up @@ -498,7 +499,10 @@ def run(self, comm, *args, **kwargs):
return run(self, comm, *args, **kwargs)

def _on_exit_sync(self, exitcode):
self._ongoing_background_tasks.call_soon(self._on_exit, exitcode)
try:
self._ongoing_background_tasks.call_soon(self._on_exit, exitcode)
except AsyncTaskGroupClosedError: # Async task group has already been closed, so the nanny is already clos(ed|ing).
pass

@log_errors
async def _on_exit(self, exitcode):
Expand Down

0 comments on commit c992f80

Please sign in to comment.