Skip to content

Commit 30ac392

Browse files
Amrou BellalounaAmrou Bellalouna
authored andcommitted
save strong references of newly created tasks in the TASKS set
1 parent 9c728df commit 30ac392

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pydis_core/utils/scheduling.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from pydis_core.utils import logging
1212

13+
TASKS = set[asyncio.Task]
14+
1315

1416
class Scheduler:
1517
"""
@@ -238,6 +240,9 @@ def create_task(
238240
task = event_loop.create_task(coro, **kwargs)
239241
else:
240242
task = asyncio.create_task(coro, **kwargs)
243+
244+
TASKS.add(task)
245+
task.add_done_callback(TASKS.discard)
241246
task.add_done_callback(partial(_log_task_exception, suppressed_exceptions=suppressed_exceptions))
242247
return task
243248

0 commit comments

Comments
 (0)