Combining Traditional Thread-Based Code and Asyncio in Python | by Peng Qian | May, 2023
There is another case where our program already implements a loop in the existing code. For example, most GUI programs use an event loop to respond to various events and to update the UI.Let’s take tkinter as an example. tkinter will start a main loop when it starts, and this main loop will block the main thread and keep on looping. As shown in the figure below:How does the tkinter main loop work. Image by AuthorA direct call to synchronous IO code will block the main loopLet’s take the example of a tkinter program that…