diff --git a/api/responder.py b/api/responder.py index 79431d5..7ad74fa 100644 --- a/api/responder.py +++ b/api/responder.py @@ -28,6 +28,10 @@ background_tasks: Set[asyncio.Task[Any]] = set() 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) background_tasks.add(task) task.add_done_callback(background_tasks.discard)