[Twisted-Python] Qtreactor problem on twisted 2.1
Hello,
Our application uses twisted as the core network framework. It
basically consists of a server and multiple clients. All communication
is carried on a twisted.spread.pb channel. We have been using twisted
1.3 since the beginning, we decided to switch to twisted 2.1, the
switch was easy but an interesting problem showed up.
Our client is based on PyQt, so uses qtreactor. If something goes
wrong on the server side, the error is transferred to the client
(automagically, thanks to twisted & deferreds), and handled there
(with an errback). We warn our users about the failure with a dialog.
The interesting part is, with twisted 2.1, at the dialog's exec_loop()
call, occasionally the connection between the server and client goes
away with the following exception:
-------------------------------------------
2005/12/30 15:51 GTB Standard Time [-] Error in <
On Dec 30, 2005, at 10:26 AM, Umit Oztosun wrote:
Hello,
Our application uses twisted as the core network framework. It basically consists of a server and multiple clients. All communication is carried on a twisted.spread.pb channel. We have been using twisted 1.3 since the beginning, we decided to switch to twisted 2.1, the switch was easy but an interesting problem showed up.
Our client is based on PyQt, so uses qtreactor. If something goes wrong on the server side, the error is transferred to the client (automagically, thanks to twisted & deferreds), and handled there (with an errback). We warn our users about the failure with a dialog. The interesting part is, with twisted 2.1, at the dialog's exec_loop() call, occasionally the connection between the server and client goes away with the following exception:
For some reason, the stack trace looks truncated, since it starts with defer.py:addCallbacks. But my guess is that read is getting called re-entrantly. By calling exec_loop within a callback, you're causing the reactor to loop within another reactor loop, and the reactor isn't designed to ensure it's safe to do that. Is it possible to change the code to show a dialog box without running a sub-loop? James
Hi,
On 12/30/05, James Y Knight
For some reason, the stack trace looks truncated, since it starts with defer.py:addCallbacks. But my guess is that read is getting called re-entrantly. By calling exec_loop within a callback, you're causing the reactor to loop within another reactor loop, and the reactor isn't designed to ensure it's safe to do that. Is it possible to change the code to show a dialog box without running a sub-loop?
Well, our dialog is a custom widget derived from QDialog. Displaying the dialog without exec_loop is not a problem, but in order to receive and process GUI events, one should somehow call qApp.processEvents() or a similar call. Otherwise GUI basically locks up. I constructed a dummy loop periodically calling qApp.processEvents() in order to simulate the exec_loop behaviour. However, the problem still persists. After a few seconds after the dialog is displayed, the "Non-list expression received" exception is fired. I even tried "qApp.eventLoop().processEvents(QEventLoop.ExcludeSocketNotifiers)" in order to only process user input events, but this again didn't work. This does not always happen, but happens quite occasionally. To emphasize again, problem does not exist when using twisted 1.3. I also tried to connect a twisted 2.1 server with a twisted 1.3 client, and it was still OK. Regards, Umit Oztosun
participants (2)
-
James Y Knight
-
Umit Oztosun