From 30ac3926f709e3263211009f9707b0ad187a956f Mon Sep 17 00:00:00 2001 From: Amrou Bellalouna Date: Mon, 12 Dec 2022 21:21:38 +0100 Subject: save strong references of newly created tasks in the `TASKS` set --- pydis_core/utils/scheduling.py | 5 +++++ 1 file changed, 5 insertions(+) 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 -- cgit v1.2.3 From 4dc7593d92b1572d43947df0cba21cf4e1feb342 Mon Sep 17 00:00:00 2001 From: Amrou Bellalouna Date: Fri, 23 Dec 2022 19:23:40 +0100 Subject: save newly created tasks in a set --- pydis_core/utils/scheduling.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pydis_core/utils/scheduling.py b/pydis_core/utils/scheduling.py index 8f9d711c..7987024c 100644 --- a/pydis_core/utils/scheduling.py +++ b/pydis_core/utils/scheduling.py @@ -10,7 +10,7 @@ from functools import partial from pydis_core.utils import logging -TASKS = set[asyncio.Task] +_background_tasks = set[asyncio.Task] class Scheduler: @@ -241,8 +241,8 @@ def create_task( else: task = asyncio.create_task(coro, **kwargs) - TASKS.add(task) - task.add_done_callback(TASKS.discard) + _background_tasks.add(task) + task.add_done_callback(_background_tasks.discard) task.add_done_callback(partial(_log_task_exception, suppressed_exceptions=suppressed_exceptions)) return task -- cgit v1.2.3 From f68399e2328a103c1ab3cd47f08920a96cb9b932 Mon Sep 17 00:00:00 2001 From: Amrou Bellalouna Date: Fri, 23 Dec 2022 19:29:09 +0100 Subject: update version and carve it in changelog --- docs/changelog.rst | 4 ++++ pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index ee4cc69c..0734158a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,10 @@ Changelog ========= + +- :release:`9.3.1 <23rd December 2022>` +- :bug:`170` Save references of newly created tasks in :obj:`pydis_core.utils.scheduling` + - :release:`9.3.0 <13th December 2022>` - :feature:`169` Return :obj:`None` upon receiving a bad request from Discord in :obj:`pydis_core.utils.members.get_or_fetch_member` diff --git a/pyproject.toml b/pyproject.toml index 482dfdca..cac29809 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pydis_core" -version = "9.3.0" +version = "9.3.1" description = "PyDis core provides core functionality and utility to the bots of the Python Discord community." authors = ["Python Discord "] license = "MIT" -- cgit v1.2.3 From 31265fddebf0179c914139eef0d8f5d279aa3932 Mon Sep 17 00:00:00 2001 From: Amrou Bellalouna Date: Fri, 23 Dec 2022 19:35:54 +0100 Subject: fix instantiation of bg tasks set --- pydis_core/utils/scheduling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydis_core/utils/scheduling.py b/pydis_core/utils/scheduling.py index 7987024c..d4458bc1 100644 --- a/pydis_core/utils/scheduling.py +++ b/pydis_core/utils/scheduling.py @@ -10,7 +10,7 @@ from functools import partial from pydis_core.utils import logging -_background_tasks = set[asyncio.Task] +_background_tasks: set[asyncio.Task] = set() class Scheduler: -- cgit v1.2.3