@@ -114,11 +114,7 @@ def loop_qt4(kernel):
114114
115115 kernel .app = get_app_qt4 ([" " ])
116116 kernel .app .setQuitOnLastWindowClosed (False )
117-
118- # Only register the eventloop for the shell stream because doing
119- # it for the control stream is generating a bunch of unnecessary
120- # warnings on Windows.
121- _notify_stream_qt (kernel , kernel .shell_streams [0 ])
117+ _notify_stream_qt (kernel , kernel .shell_stream )
122118
123119 _loop_qt (kernel .app )
124120
@@ -160,10 +156,9 @@ def loop_wx(kernel):
160156
161157 def wake ():
162158 """wake from wx"""
163- for stream in kernel .shell_streams :
164- if stream .flush (limit = 1 ):
165- kernel .app .ExitMainLoop ()
166- return
159+ if kernel .shell_stream .flush (limit = 1 ):
160+ kernel .app .ExitMainLoop ()
161+ return
167162
168163 # We have to put the wx.Timer in a wx.Frame for it to fire properly.
169164 # We make the Frame hidden when we create it in the main app below.
@@ -237,13 +232,12 @@ def process_stream_events(stream, *a, **kw):
237232 # For Tkinter, we create a Tk object and call its withdraw method.
238233 kernel .app_wrapper = BasicAppWrapper (app )
239234
240- for stream in kernel .shell_streams :
241- notifier = partial (process_stream_events , stream )
242- # seems to be needed for tk
243- notifier .__name__ = "notifier"
244- app .tk .createfilehandler (stream .getsockopt (zmq .FD ), READABLE , notifier )
245- # schedule initial call after start
246- app .after (0 , notifier )
235+ notifier = partial (process_stream_events , shell_stream )
236+ # seems to be needed for tk
237+ notifier .__name__ = "notifier"
238+ app .tk .createfilehandler (shell_stream .getsockopt (zmq .FD ), READABLE , notifier )
239+ # schedule initial call after start
240+ app .after (0 , notifier )
247241
248242 app .mainloop ()
249243
@@ -330,10 +324,9 @@ def handle_int(etype, value, tb):
330324 # don't let interrupts during mainloop invoke crash_handler:
331325 sys .excepthook = handle_int
332326 mainloop (kernel ._poll_interval )
333- for stream in kernel .shell_streams :
334- if stream .flush (limit = 1 ):
335- # events to process, return control to kernel
336- return
327+ if kernel_shell_stream .flush (limit = 1 ):
328+ # events to process, return control to kernel
329+ return
337330 except :
338331 raise
339332 except KeyboardInterrupt :
@@ -371,11 +364,9 @@ def process_stream_events(stream):
371364 if stream .flush (limit = 1 ):
372365 loop .stop ()
373366
374- for stream in kernel .shell_streams :
375- fd = stream .getsockopt (zmq .FD )
376- notifier = partial (process_stream_events , stream )
377- loop .add_reader (fd , notifier )
378- loop .call_soon (notifier )
367+ notifier = partial (process_stream_events , shell_stream )
368+ loop .add_reader (shell_stream .getsockopt (zmq .FD ), notifier )
369+ loop .call_soon (notifier )
379370
380371 while True :
381372 error = None
0 commit comments