-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Qt Ctrl-C broken on windows #20932
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
Comments
Is it the current |
Here how it looks like, I don't think it is the same QSocketNotifier, it is a different object every time. But false-trigger only happens if the |
Does something like this work? import select
import socket
for i in range(10):
wsock, rsock = socket.socketpair()
wsock.setblocking(False)
rfd = rsock.fileno()
wfd = wsock.fileno()
print('rsock:', rfd, 'wsock:', wfd)
ready = select.select([rfd], [], [], 2)
print('ready:', ready)
wsock.close()
rsock.close() It should print out that no sockets are ready. Windows support was only added in 3.5, but maybe there's a bug? Maybe we should call
|
Also, does reusing the existing socket pair work? wsock, rsock = socket.socketpair()
wsock.setblocking(False)
sn = QtCore.QSocketNotifier(
rsock.fileno(), _enum('QtCore.QSocketNotifier.Type').Read
)
sn.activated.connect(lambda *args: print('activated 1'))
del sn
sn = QtCore.QSocketNotifier(
rsock.fileno(), _enum('QtCore.QSocketNotifier.Type').Read
)
sn.activated.connect(lambda *args: print('activated 2')) |
Actually, for that second test, maybe we should run the event loop in between? wsock, rsock = socket.socketpair()
wsock.setblocking(False)
sn = QtCore.QSocketNotifier(
rsock.fileno(), _enum('QtCore.QSocketNotifier.Type').Read
)
sn.activated.connect(lambda *args: print('activated 1'))
# 5 seconds of event processing should be enough?
event_loop = QtCore.QEventLoop()
timer = QtCore.QTimer.singleShot(5000, event_loop.quit)
qt_compat._exec(event_loop)
del sn
sn = QtCore.QSocketNotifier(
rsock.fileno(), _enum('QtCore.QSocketNotifier.Type').Read
)
sn.activated.connect(lambda *args: print('activated 2'))
# 5 seconds of event processing should be enough?
event_loop = QtCore.QEventLoop()
timer = QtCore.QTimer.singleShot(5000, event_loop.quit)
qt_compat._exec(event_loop) |
@QuLogic For some reason, the event loop does not exit after 5s and then the program hangs... I've obtained the previous results by running %matplotlib qt first (it probably starts the event loop correctly by itself) |
Is this fixed by #20907? |
It should be. |
@anntzer @tacaswell
Hi! I have just tested the master branch on Windows and found that there is indeed a problem with the QSocketNotifier (it appeared here: #13306 (comment)). Previously, on that Windows machine, I was running my old code with QAbstractSocket which was fine, and did not test the newest version with QSocketNotifier there (my fault, sorry). I have tested on Linux, and there is no such problem there.
The code to reproduce on Windows (in Jupyter):
The problem seems to be that if
socketpair
generates a socket with the samefileno
value as it generated in the previouspause()
call, the QSocketNotifier unexpectedly fires and hangs here:matplotlib/lib/matplotlib/backends/qt_compat.py
Line 232 in b600026
because nothing was actually written to the
wakeup_fd
. I don't understand how that can be.Workaround fix:
What should we do with this? Is there a better solution?
Originally posted by @vdrhtc in #13306 (comment)
The text was updated successfully, but these errors were encountered: