MCPcopy Index your code
hub / github.com/python/cpython / shutdown_asyncgens

Method shutdown_asyncgens

Lib/asyncio/base_events.py:575–598  ·  view source on GitHub ↗

Shutdown all active asynchronous generators.

(self)

Source from the content-addressed store, hash-verified

573 self._asyncgens.add(agen)
574
575 async def shutdown_asyncgens(self):
576 """Shutdown all active asynchronous generators."""
577 self._asyncgens_shutdown_called = True
578
579 if not len(self._asyncgens):
580 # If Python version is <3.6 or we don't have any asynchronous
581 # generators alive.
582 return
583
584 closing_agens = list(self._asyncgens)
585 self._asyncgens.clear()
586
587 results = await tasks.gather(
588 *[ag.aclose() for ag in closing_agens],
589 return_exceptions=True)
590
591 for result, agen in zip(results, closing_agens):
592 if isinstance(result, Exception):
593 self.call_exception_handler({
594 'message': f'an error occurred during closing of '
595 f'asynchronous generator {agen!r}',
596 'exception': result,
597 'asyncgen': agen
598 })
599
600 async def shutdown_default_executor(self, timeout=None):
601 """Schedule the shutdown of the default executor.

Callers

nothing calls this directly

Calls 5

listClass · 0.85
clearMethod · 0.45
gatherMethod · 0.45
acloseMethod · 0.45

Tested by

no test coverage detected