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

Fix QSocketNotifier in the Qt event loop not being disabled for the control channel #525

Merged
merged 1 commit into from
Jul 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def process_stream_events():
if stream.flush(limit=1):
notifier.setEnabled(False)
kernel.app.quit()
else:
# Even if there's nothing to flush, we need to disable the
# notifier in order to connect a new one in the next
# execution. This applies to the control channel.
notifier.setEnabled(False)
kernel.app.quit()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't putting this in an else make the entire if/else block unnecessary (both True/False cases run the exact same code)?

Copy link
Member Author

@ccordoba12 ccordoba12 Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that too, but the if also flushes the shell channel. So perhaps I should rewrite this to

stream.flush(limit=1)
notifier.setEnabled(False)
kernel.app.quit()

?


fd = stream.getsockopt(zmq.FD)
notifier = QtCore.QSocketNotifier(fd, QtCore.QSocketNotifier.Read, kernel.app)
Expand Down