File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ def all_tasks(loop=None):
42
42
"""Return a set of all tasks for the loop."""
43
43
if loop is None :
44
44
loop = events .get_running_loop ()
45
- return {t for t in _all_tasks
45
+ # NB: set(_all_tasks) is required to protect
46
+ # from https://bugs.python.org/issue34970 bug
47
+ return {t for t in list (_all_tasks )
46
48
if futures ._get_loop (t ) is loop and not t .done ()}
47
49
48
50
@@ -52,7 +54,9 @@ def _all_tasks_compat(loop=None):
52
54
# method.
53
55
if loop is None :
54
56
loop = events .get_event_loop ()
55
- return {t for t in _all_tasks if futures ._get_loop (t ) is loop }
57
+ # NB: set(_all_tasks) is required to protect
58
+ # from https://bugs.python.org/issue34970 bug
59
+ return {t for t in list (_all_tasks ) if futures ._get_loop (t ) is loop }
56
60
57
61
58
62
def _set_task_name (task , name ):
Original file line number Diff line number Diff line change
1
+ Protect tasks weak set manipulation in ``asyncio.all_tasks() ``
You can’t perform that action at this time.
0 commit comments