Skip to content
Merged
Show file tree
Hide file tree
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: 6 additions & 2 deletions Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def all_tasks(loop=None):
"""Return a set of all tasks for the loop."""
if loop is None:
loop = events.get_running_loop()
return {t for t in _all_tasks
# NB: set(_all_tasks) is required to protect
# from https://bugs.python.org/issue34970 bug
return {t for t in list(_all_tasks)
if futures._get_loop(t) is loop and not t.done()}


Expand All @@ -52,7 +54,9 @@ def _all_tasks_compat(loop=None):
# method.
if loop is None:
loop = events.get_event_loop()
return {t for t in _all_tasks if futures._get_loop(t) is loop}
# NB: set(_all_tasks) is required to protect
# from https://bugs.python.org/issue34970 bug
return {t for t in list(_all_tasks) if futures._get_loop(t) is loop}


def _set_task_name(task, name):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Protect tasks weak set manipulation in ``asyncio.all_tasks()``