Skip to content

Commit ae1520e

Browse files
Merge pull request #170 from shtlrs/140-save-references-of-created-tasks
Save references of newly created taks
2 parents 00b4f16 + 31265fd commit ae1520e

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

docs/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
Changelog
55
=========
66

7+
8+
- :release:`9.3.1 <23rd December 2022>`
9+
- :bug:`170` Save references of newly created tasks in :obj:`pydis_core.utils.scheduling`
10+
711
- :release:`9.3.0 <13th December 2022>`
812
- :feature:`169` Return :obj:`None` upon receiving a bad request from Discord in :obj:`pydis_core.utils.members.get_or_fetch_member`
913

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+
_background_tasks: set[asyncio.Task] = set()
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+
_background_tasks.add(task)
245+
task.add_done_callback(_background_tasks.discard)
241246
task.add_done_callback(partial(_log_task_exception, suppressed_exceptions=suppressed_exceptions))
242247
return task
243248

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pydis_core"
3-
version = "9.3.0"
3+
version = "9.3.1"
44
description = "PyDis core provides core functionality and utility to the bots of the Python Discord community."
55
authors = ["Python Discord <info@pythondiscord.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)