You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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 problem seems to be that if socketpair generates a socket with the same fileno value as it generated in the previous pause() call, the QSocketNotifier unexpectedly fires and hangs here:
because nothing was actually written to the wakeup_fd. I don't understand how that can be.
Workaround fix:
rsock.set_blocking(False)
@sn.activated.connectdefon_signal(*args):
try:
signal=rsock.recv(1) # clear the socket to re-arm the notifierexceptBlockingIOError:
pass# false-trigger, nothing on rsock
What should we do with this? Is there a better solution?
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 fileno is re-used (1092 in this case, for 1028 nothing happens). So maybe it is necessary to clear the rsock somehow.
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 socket.shutdown on the sockets to force them to be disabled, even though we do close them:
Shut down one or both halves of the connection. If how is SHUT_RD, further receives are disallowed. If how is SHUT_WR, further sends are disallowed. If how is SHUT_RDWR, further sends and receives are disallowed.
Nothing unexpected in the first test despite occasional re-uses:
Second test also works:
If I remove the del sn line, then there is a warning about multiple notifiers for the same socket in the terminal, and no activation happens on both notifiers.
Activity
QuLogic commentedon Aug 30, 2021
Is it the current
QSocketNotifierthat fires, or the previous one? Are we just missing some cleanup?vdrhtc commentedon Aug 31, 2021
@QuLogic

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
filenois re-used (1092 in this case, for 1028 nothing happens). So maybe it is necessary to clear the rsock somehow.QuLogic commentedon Sep 1, 2021
Does something like this work?
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
socket.shutdownon the sockets to force them to be disabled, even though we do close them:QuLogic commentedon Sep 1, 2021
Also, does reusing the existing socket pair work?
vdrhtc commentedon Sep 1, 2021
Nothing unexpected in the first test despite occasional re-uses:

Second test also works:

If I remove the
del snline, then there is a warning about multiple notifiers for the same socket in the terminal, and no activation happens on both notifiers.Calling
does not help.
QuLogic commentedon Sep 1, 2021
Actually, for that second test, maybe we should run the event loop in between?
vdrhtc commentedon Sep 16, 2021
@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)
timhoffm commentedon Oct 1, 2021
Is this fixed by #20907?
QuLogic commentedon Oct 1, 2021
It should be.