Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactor not stopped when window closed #22

Open
estan opened this issue Apr 14, 2015 · 8 comments
Open

Reactor not stopped when window closed #22

estan opened this issue Apr 14, 2015 · 8 comments

Comments

@estan
Copy link

estan commented Apr 14, 2015

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
Copy link
Author

estan commented May 8, 2015

@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
Copy link
Author

estan commented Nov 3, 2015

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
Copy link
Author

estan commented Nov 3, 2015

I have a patch for @sunu's qt5reactor: twisted/qt5reactor#1

The fix is simple enough, do you think you could make it in qtreactor as well?

@ghtdak
Copy link
Owner

ghtdak commented Nov 3, 2015

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:
twisted/qt5reactor#1 twisted/qt5reactor#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
=]|[=

@estan
Copy link
Author

estan commented Nov 3, 2015

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
Copy link
Author

estan commented Nov 4, 2015

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
Copy link
Author

estan commented Nov 5, 2015

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

@mFoxRU
Copy link

mFoxRU commented Dec 27, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants