I have developed a prototype that has a PySide6 (Qt for Python) GUI running in the main thread. In a secondary thread, an asyncio
event loop is running several tasks that are orchestrated via the AsyncController
class, which implements the standard OOP state pattern. The GUI talks to the AsyncController
via an asyncio.Queue
by putting items on the queue via asyncio.run_coroutine_threadsafe
. The AsyncController
communicates back to the GUI using Qt’s Signal
mechanism. Then I have a small worker/actor framework that allows one to build AsyncWorker
s that can communicate via AsyncInbox
s, which are just a small abstraction over asyncio.Queue
.
The code is here: bmitc/pyside-asyncio-prototype (github.com)
The prototype implements the following application and architecture:
Documentation of the prototype’s class and module relationships are located here: pyside-asyncio-prototype/documentation at main · bmitc/pyside-asyncio-prototype (github.com)
Specifically, the core relationships look like:
I would love to hear any feedback on the overall approach or detailed review of the code. Please place the review here rather than creating any issues or pull requests in the repository.
My primary question is how well this will scale. The intention here is for many AsyncWorker
s to serve as the basis for many (dozens) of networked clients that talk to hardware. Thus, the data rates will be somewhat at times and status from all networked hardware devices will be desired at around 10Hz, ideally. Of course, availability and robustness (in the form of network communication or hardware failures) of all the workers and the main controller are a primary objective. So the question is how well this architecture scales to meet those needs. Since this architecture is actually just a relatively thin layer over asyncio
primitives, it’s also really a question of how asyncio
scales as well for this use case.
Thank you ahead of time for anyone who times the time to take a look at this. There weren’t many examples of such an architecture, so it took some time to create this. But I am actually pretty happy with it and would like a gut check whether I should remain happy about it. Thank you.