Python: asyncio and Tkinter

Chris Angelico rosuav at gmail.com
Wed Dec 20 08:42:47 EST 2017


On Wed, Dec 20, 2017 at 10:42 AM,  <c.buhtz at posteo.jp> wrote:
> I am looking for an "elegant" and "official" way to use asyncio in
> Tkinter applications. The goal is that the GUI is not freezing while
> doing some download-tasks (over 100 files from different locations).
>
> ...
>
> I think about combining asyncio with multithreading so the asyncio
> event loop has it's own thread and is not blocking the GUI event loop.
> Or using only multithreading.

I would recommend threading. You can run your GUI event loop on one
thread, and your network I/O loop on another thread. Both threads
spend the bulk of their time blocked on I/O, and you've limited
yourself to a finite number of threads (as opposed to a pure threaded
approach with every download is run on a separate thread), so resource
consumption should be reasonable.

ChrisA



More information about the Python-list mailing list