[PySide] Unifying Qt and Python asyncio?

Marian Beermann public at enkore.de
Sun Dec 27 17:05:37 CET 2020


There are two very different approaches to solve this problem:

1.) Run both event loops by polling one loop as a task within the other.
This has numerous hard-to-fix problems, like poor/unpredictable latency,
issues with unblocking tasks across the loops, logic bugs because e.g.
UI events are processed in batches between batches of coroutine
resumptions etc.

This is what e.g. wxasync does for wxPython. Would not generally
recommend doing this, has quite a lot of potential for headaches.

2.) Run Python coroutines using the "foreign" event loop. I believe
asyncqt mostly implements an asyncio event loop + policy so the asyncio
event loop *is* the Qt event loop. A very good solution. If asyncio
itself is not needed per se, more lightweight approaches are possible (I
wrote asynker a few years ago for this purpose).

Cheers, Marian


More information about the PySide mailing list