qt5reactor
qt5reactor copied to clipboard
Self-interrupting code: QtReactor.doIteration() calling processEvents()
I started with my first Twisted code in a standalone script though still using PyQt5 due to some of my leveraged code for CANbus interfacing. This went quite well but when I started to integrate it back into my application I ran into trouble after adding feedback from 'the twisted code' to a QProgressDialog
. It didn't matter if I used a signal/slot or called directly to QProgressDialog.setValue()
, I would quickly get my code interrupted (within the same thread) resulting in receiving a network response (coming in via a signal/slot connection) before I finished the post-send code.
While the python-can
library underlying my CANbus communication does use a thread from which it provides incoming messages, I have all of those routed through signals/slots to hop the thread boundary safely. I also double checked and the code that was seemingly interrupted and the supposed interrupting code both report the same threading.get_ident()
. This suggests to me that it isn't a threading issue (though... I'm not ruling it out. :]
).
See my (to be linked) commit that alleviates this. I will also link my code once I have the exact revision pushed.
main: https://github.com/altendky/st/tree/2b42d6577de5511ad091ecf7d2830135a1126e56 lib submodule: https://github.com/altendky/st/tree/35c327c8abc7f098fecfeabed8614668517048fb
Nice catch on noticing that QTimer wasn't using fromqt
.
Would you like to open up a pull request for this (against current master)?