aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_core/utils/scheduling.py
diff options
context:
space:
mode:
authorGravatar Amrou Bellalouna <[email protected]>2022-12-12 21:21:38 +0100
committerGravatar Amrou Bellalouna <[email protected]>2022-12-12 21:21:38 +0100
commit30ac3926f709e3263211009f9707b0ad187a956f (patch)
treeefcca9d6b7dbcff6ab58532e38990dc8d8892509 /pydis_core/utils/scheduling.py
parentMerge pull request #151 from python-discord/Python-3.11 (diff)
save strong references of newly created tasks in the `TASKS` set
Diffstat (limited to 'pydis_core/utils/scheduling.py')
-rw-r--r--pydis_core/utils/scheduling.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/pydis_core/utils/scheduling.py b/pydis_core/utils/scheduling.py
index eced4a3d..8f9d711c 100644
--- a/pydis_core/utils/scheduling.py
+++ b/pydis_core/utils/scheduling.py
@@ -10,6 +10,8 @@ from functools import partial
from pydis_core.utils import logging
+TASKS = set[asyncio.Task]
+
class Scheduler:
"""
@@ -238,6 +240,9 @@ def create_task(
task = event_loop.create_task(coro, **kwargs)
else:
task = asyncio.create_task(coro, **kwargs)
+
+ TASKS.add(task)
+ task.add_done_callback(TASKS.discard)
task.add_done_callback(partial(_log_task_exception, suppressed_exceptions=suppressed_exceptions))
return task