qtreactor
qtreactor copied to clipboard
Reactor not stopped when window closed
I'm wonder whether the issue in #3 has bubbled up again (see my comments there). At least the reactor does not stop when I close the dialog in the following test case:
from sys import argv, exit
from PyQt4.QtGui import QDialog, QApplication
import qt4reactor
if __name__ == '__main__':
app = QApplication(argv)
app.setQuitOnLastWindowClosed(True)
qt4reactor.install()
from twisted.internet import reactor
dialog = QDialog()
dialog.show()
reactor.run()
exit(0)
I have the same problem when running e.g. the ghtTests/trivial_gui_script.py
example.
Is anyone else seeing this? I'm opening this issue since I got no response on #3, and this might be another issue with the same symptom. This is with PyQt 4.11.3, Qt 4.8.6, Twisted 15.0.0 and Python 2.7.9.
@ghtdak Is this project alive? I'd really need some kind of fix for this, since we're using qtreactor for several of our HMIs here at work, but I'm really not savvy enough with the reactor to come up with a fix myself. I could try to debug it though.
It seems issues here on GitHub have been left as-is for about 6 months now :/
I think this is due to threads still running in reactor.threadpool. I'm seeing this issue also in qt5reactor. If I do if reactor.threadpool is not None: reactor.threadpool.stop()
, the application exits properly. I think qtreactor needs to do this when the reactor is stopped.
I have a patch for @sunu's qt5reactor: https://github.com/sunu/qt5reactor/pull/1
The fix is simple enough, do you think you could make it in qtreactor as well?
On Tue, Nov 3, 2015 at 2:25 PM, Elvis Stansvik [email protected] wrote:
I have a patch for @sunu https://github.com/sunu's qt5reactor: sunu/qt5reactor#1 https://github.com/sunu/qt5reactor/pull/1
The fix is simple enough, do you think you could make it in qtreactor as well?
Sure. Once its been tested with qt5reactor, I'll include it.
Glenn H. Tarbox, PhD =]|[=
Great. I've realized now that it's a little hard to reproduce it, and that my test app on that pull request does not always reproduce the problem. I'll see if I can make something more robust.
I've found a better/more general fix for the problem, and a test case that clearly demonstrates the issue. Turns out that the 'shutdown' system event triggers were not running when the application quits, which ReactorBase
uses internally to stop its threadpool. A new pull request for qt5reactor is here.
@ghtdak: The fix has now been merged into qt5reactor
.
@ghtdak So... Any chance qt4reactor will also be patched? The @estan's fix seem to work for pyqt4. (Well, it still doesn't work for pycharm, but I think it's a pycharm's problem) I can make a pull request if you both don't have time.