From 93eca8a756cf751b2182047b2ecd0f73e0d3dace Mon Sep 17 00:00:00 2001 From: Alexander Stukowski Date: Fri, 22 Oct 2021 15:18:27 +0200 Subject: [PATCH] Clean up QTimer/QSocketNotifier when exiting Qt event loop --- ipykernel/eventloops.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ipykernel/eventloops.py b/ipykernel/eventloops.py index 1f7f47f3e..eade2d457 100644 --- a/ipykernel/eventloops.py +++ b/ipykernel/eventloops.py @@ -39,6 +39,7 @@ def process_stream_events(): fd = stream.getsockopt(zmq.FD) notifier = QtCore.QSocketNotifier(fd, QtCore.QSocketNotifier.Read, kernel.app) notifier.activated.connect(process_stream_events) + notifier.activated.connect(notifier.deleteLater) # there may already be unprocessed events waiting. # these events will not wake zmq's edge-triggered FD # since edge-triggered notification only occurs on new i/o activity. @@ -49,6 +50,7 @@ def process_stream_events(): timer = QtCore.QTimer(kernel.app) timer.setSingleShot(True) timer.timeout.connect(process_stream_events) + timer.timeout.connect(timer.deleteLater) timer.start(0) # mapping of keys to loop functions