def _do_shutdown(self, future):
try:
self._default_executor.shutdown(wait=True)
- self.call_soon_threadsafe(future.set_result, None)
+ if not self.is_closed():
+ self.call_soon_threadsafe(future.set_result, None)
except Exception as ex:
- self.call_soon_threadsafe(future.set_exception, ex)
+ if not self.is_closed():
+ self.call_soon_threadsafe(future.set_exception, ex)
def _check_running(self):
if self.is_running():
if dest_loop is None or dest_loop is source_loop:
_set_state(destination, source)
else:
+ if dest_loop.is_closed():
+ return
dest_loop.call_soon_threadsafe(_set_state, destination, source)
destination.add_done_callback(_call_check_cancel)