qtreactor icon indicating copy to clipboard operation
qtreactor copied to clipboard

Reactor not stopped when window closed

Open estan opened this issue 9 years ago • 8 comments

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.

estan avatar Apr 14 '15 17:04 estan

@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 :/

estan avatar May 08 '15 05:05 estan

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.

estan avatar Nov 03 '15 21:11 estan

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?

estan avatar Nov 03 '15 22:11 estan

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 =]|[=

ghtdak avatar Nov 03 '15 22:11 ghtdak

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.

estan avatar Nov 03 '15 22:11 estan

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.

estan avatar Nov 04 '15 11:11 estan

@ghtdak: The fix has now been merged into qt5reactor.

estan avatar Nov 05 '15 15:11 estan

@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.

mFoxRU avatar Dec 27 '15 08:12 mFoxRU