Skip to content

Commit c880f94

Browse files
committed
Replace asyncio.ensure_future() (deprecated since Python 3.10) with asyncio.create_task()
1 parent 72daf74 commit c880f94

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

async_tkinter_loop/async_tkinter_loop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ async def some_async_function():
6464
6565
button = tk.Button("Press me", command=some_async_function)
6666
"""
67-
return lambda *handler_args: asyncio.ensure_future(command(*handler_args, *args, **kwargs))
67+
return lambda *handler_args: asyncio.create_task(command(*handler_args, *args, **kwargs))

examples/start_stop_counter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def start_stop():
3131
event = asyncio.Event()
3232

3333
# Start background task
34-
asyncio.ensure_future(counter(event)) # use asyncio.create_task() instead of ensure_future on Python 3.7+
34+
asyncio.get_event_loop().create_task(counter(event))
3535

3636
if __name__ == "__main__":
3737
async_mainloop(root)

0 commit comments

Comments
 (0)