mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com> Co-authored-by: Jacob Coffee <jacob@z7x.org> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
parent
60a3a0dd6f
commit
188598851d
23 changed files with 2923 additions and 241 deletions
|
@ -6,6 +6,7 @@ __all__ = ("TaskGroup",)
|
|||
|
||||
from . import events
|
||||
from . import exceptions
|
||||
from . import futures
|
||||
from . import tasks
|
||||
|
||||
|
||||
|
@ -197,6 +198,8 @@ class TaskGroup:
|
|||
else:
|
||||
task = self._loop.create_task(coro, name=name, context=context)
|
||||
|
||||
futures.future_add_to_awaited_by(task, self._parent_task)
|
||||
|
||||
# Always schedule the done callback even if the task is
|
||||
# already done (e.g. if the coro was able to complete eagerly),
|
||||
# otherwise if the task completes with an exception then it will cancel
|
||||
|
@ -228,6 +231,8 @@ class TaskGroup:
|
|||
def _on_task_done(self, task):
|
||||
self._tasks.discard(task)
|
||||
|
||||
futures.future_discard_from_awaited_by(task, self._parent_task)
|
||||
|
||||
if self._on_completed_fut is not None and not self._tasks:
|
||||
if not self._on_completed_fut.done():
|
||||
self._on_completed_fut.set_result(True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue