Skip to content

Commit 730a812

Browse files
committed
Check if the current thread is the io thread
1 parent 378af4b commit 730a812

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ipykernel/iostream.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,12 @@ def flush(self):
455455
456456
send will happen in the background thread
457457
"""
458-
if self.pub_thread and self.pub_thread.thread is not None and self.pub_thread.thread.is_alive():
458+
if (
459+
self.pub_thread
460+
and self.pub_thread.thread is not None
461+
and self.pub_thread.thread.is_alive()
462+
and self.pub_thread.thread.ident != threading.current_thread().ident
463+
):
459464
# request flush on the background thread
460465
self.pub_thread.schedule(self._flush)
461466
# wait for flush to actually get through, if we can.

0 commit comments

Comments
 (0)