Using asyncio with tkinter and it's ttk.progressbar widget: how to force an asyncio task to end? Using asyncio with tkinter and it's ttk.progressbar widget: how to force an asyncio task to end? tkinter tkinter

Using asyncio with tkinter and it's ttk.progressbar widget: how to force an asyncio task to end?


Use run_until_complete and when you cancel the task you'll drop out of the function. You were using run_forever and not stopping the loop so you never got past that function.

    loop.run_until_complete(root.update_task)    #loop.run_forever()

Also see the doc for run_forever

loop.run_forever()    Run the event loop until stop() is called.