@@ -59,13 +59,41 @@ def _update_eventloop(self, change):
5959 profile_dir = Instance ('IPython.core.profiledir.ProfileDir' , allow_none = True )
6060 shell_stream = Instance (ZMQStream , allow_none = True )
6161
62- @property
63- def shell_streams (self ):
62+ shell_streams = List (
63+ help = """Deprecated shell_streams alias. Use shell_stream
64+
65+ .. versionchanged:: 6.0
66+ shell_streams is deprecated. Use shell_stream.
67+ """
68+ )
69+
70+ @default ("shell_streams" )
71+ def _shell_streams_default (self ):
6472 warnings .warn (
65- 'Property shell_streams is deprecated in favor of shell_stream' ,
66- DeprecationWarning
73+ "Kernel.shell_streams is deprecated in ipykernel 6.0. Use Kernel.shell_stream" ,
74+ DeprecationWarning ,
75+ stacklevel = 2 ,
6776 )
68- return [self .shell_stream ]
77+ if self .shell_stream is not None :
78+ return [self .shell_stream ]
79+ else :
80+ return []
81+
82+ @observe ("shell_streams" )
83+ def _shell_streams_changed (self , change ):
84+ warnings .warn (
85+ "Kernel.shell_streams is deprecated in ipykernel 6.0. Use Kernel.shell_stream" ,
86+ DeprecationWarning ,
87+ stacklevel = 2 ,
88+ )
89+ if len (change .new ) > 1 :
90+ warnings .warn (
91+ "Kernel only supports one shell stream. Additional streams will be ignored." ,
92+ RuntimeWarning ,
93+ stacklevel = 2 ,
94+ )
95+ if change .new :
96+ self .shell_stream = change .new [0 ]
6997
7098 control_stream = Instance (ZMQStream , allow_none = True )
7199
@@ -177,8 +205,6 @@ def __init__(self, **kwargs):
177205 self .control_handlers [msg_type ] = getattr (self , msg_type )
178206
179207 self .control_queue = Queue ()
180- if 'control_thread' in kwargs :
181- kwargs ['control_thread' ].io_loop .add_callback (self .poll_control_queue )
182208
183209 @gen .coroutine
184210 def dispatch_control (self , msg ):
@@ -424,6 +450,13 @@ def start(self):
424450
425451 self .control_stream .on_recv (self .dispatch_control , copy = False )
426452
453+ if self .control_thread :
454+ control_loop = self .control_thread .io_loop
455+ else :
456+ control_loop = self .io_loop
457+
458+ control_loop .add_callback (self .poll_control_queue )
459+
427460 self .shell_stream .on_recv (
428461 partial (
429462 self .schedule_dispatch ,
0 commit comments