mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 18:13:56 +01:00
Add docstring to create_background_task
This commit is contained in:
parent
266aa3e0fe
commit
0b08c5b712
|
@ -28,6 +28,10 @@ background_tasks: Set[asyncio.Task[Any]] = set()
|
||||||
|
|
||||||
|
|
||||||
def create_background_task(coro: Coroutine[Any, Any, Any]) -> None:
|
def create_background_task(coro: Coroutine[Any, Any, Any]) -> None:
|
||||||
|
"""asyncio.create_task, which prevents the task from being garbage collected.
|
||||||
|
|
||||||
|
https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
|
||||||
|
"""
|
||||||
task = asyncio.create_task(coro)
|
task = asyncio.create_task(coro)
|
||||||
background_tasks.add(task)
|
background_tasks.add(task)
|
||||||
task.add_done_callback(background_tasks.discard)
|
task.add_done_callback(background_tasks.discard)
|
||||||
|
|
Loading…
Reference in a new issue