[Twisted-Python] How to combine two eventloops into one?
Hi, We are developing a network-facing GUI software. One team member builds the GUI software, which is based on PyQT and the eventloop is qt5reactor. Another team member writes the network functions, which is based on the https://github.com/bmuller/kademlia repo. Again, our code is built upon twisted, but to account for the kademila package, we switch the underlying event loop to asyncio. Now the problem comes as to how to integrate the GUI (qt5reactor) with the network(aysncio) eventloop? Possible to build a meta eventloop that combines qt5reactor and asyncio? Otherwise, any better approach? TIA. -- Best, Shiyao
On May 21, 2018, at 2:22 AM, Shiyao MA <i@introo.me> wrote:
Hi,
We are developing a network-facing GUI software.
One team member builds the GUI software, which is based on PyQT and the eventloop is qt5reactor.
Another team member writes the network functions, which is based on the https://github.com/bmuller/kademlia repo. Again, our code is built upon twisted, but to account for the kademila package, we switch the underlying event loop to asyncio.
Now the problem comes as to how to integrate the GUI (qt5reactor) with the network(aysncio) eventloop?
Possible to build a meta eventloop that combines qt5reactor and asyncio? Otherwise, any better approach?
It's definitely possible. Right now, the integration we've implemented puts asyncio "on the bottom" and twisted "on top"; in the sense that twisted.internet.asyncioreactor implements the Twisted reactor API in terms of the native asyncio event loop. It would also be possible to implement the asyncio event loop interface, as specified in https://www.python.org/dev/peps/pep-3156/#event-loop-interface-specification <https://www.python.org/dev/peps/pep-3156/#event-loop-interface-specification>, in terms of the Twisted reactor interfaces. Many of the methods are quite similar. If we had such a wrapper in Twisted already, you could wrap your qt5reactor instance in a ReactorLoop() and install that into asyncio using an event loop policy. I hope someone will contribute this ;-). -g
participants (2)
-
Glyph
-
Shiyao MA