Skip to content

Commit 7e45b22

Browse files
joouhajonathanslenders
authored andcommitted
Create background tasks on application's loop
1 parent 8d51dcd commit 7e45b22

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/prompt_toolkit/application/application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,8 @@ def create_background_task(
10771077
10781078
This is not threadsafe.
10791079
"""
1080-
task: asyncio.Task[None] = get_event_loop().create_task(coroutine)
1080+
loop = self.loop or get_event_loop()
1081+
task: asyncio.Task[None] = loop.create_task(coroutine)
10811082
self._background_tasks.add(task)
10821083

10831084
task.add_done_callback(self._on_background_task_done)

0 commit comments

Comments
 (0)