@@ -131,28 +131,16 @@ def create_stream(self):
131
131
def nudge (self ):
132
132
"""Nudge the zmq connections with kernel_info_requests
133
133
Returns a Future that will resolve when we have received
134
- a shell reply and at least one iopub message,
134
+ a control reply and at least one iopub message,
135
135
ensuring that zmq subscriptions are established,
136
136
sockets are fully connected, and kernel is responsive.
137
137
Keeps retrying kernel_info_request until these are both received.
138
138
"""
139
139
kernel = self .kernel_manager .get_kernel (self .kernel_id )
140
140
141
- # Do not nudge busy kernels as kernel info requests sent to shell are
142
- # queued behind execution requests.
143
- # nudging in this case would cause a potentially very long wait
144
- # before connections are opened,
145
- # plus it is *very* unlikely that a busy kernel will not finish
146
- # establishing its zmq subscriptions before processing the next request.
147
- if getattr (kernel , "execution_state" ) == "busy" :
148
- self .log .debug ("Nudge: not nudging busy kernel %s" , self .kernel_id )
149
- f = Future ()
150
- f .set_result (None )
151
- return f
152
-
153
- # Use a transient shell channel to prevent leaking
154
- # shell responses to the front-end.
155
- shell_channel = kernel .connect_shell ()
141
+ # Use a transient control channel to prevent leaking
142
+ # control responses to the front-end.
143
+ control_channel = kernel .connect_control ()
156
144
# The IOPub used by the client, whose subscriptions we are verifying.
157
145
iopub_channel = self .channels ["iopub" ]
158
146
@@ -172,13 +160,13 @@ def cleanup(_=None):
172
160
"""Common cleanup"""
173
161
loop .remove_timeout (nudge_handle )
174
162
iopub_channel .stop_on_recv ()
175
- if not shell_channel .closed ():
176
- shell_channel .close ()
163
+ if not control_channel .closed ():
164
+ control_channel .close ()
177
165
178
166
# trigger cleanup when both message futures are resolved
179
167
both_done .add_done_callback (cleanup )
180
168
181
- def on_shell_reply (msg ):
169
+ def on_control_reply (msg ):
182
170
self .log .debug ("Nudge: shell info reply received: %s" , self .kernel_id )
183
171
if not info_future .done ():
184
172
self .log .debug ("Nudge: resolving shell future: %s" , self .kernel_id )
@@ -192,7 +180,7 @@ def on_iopub(msg):
192
180
iopub_future .set_result (None )
193
181
194
182
iopub_channel .on_recv (on_iopub )
195
- shell_channel .on_recv (on_shell_reply )
183
+ control_channel .on_recv (on_control_reply )
196
184
loop = IOLoop .current ()
197
185
198
186
# Nudge the kernel with kernel info requests until we get an IOPub message
@@ -213,15 +201,15 @@ def nudge(count):
213
201
return
214
202
215
203
# check for closed zmq socket
216
- if shell_channel .closed ():
204
+ if control_channel .closed ():
217
205
self .log .debug ("Nudge: cancelling on closed zmq socket: %s" , self .kernel_id )
218
206
finish ()
219
207
return
220
208
221
209
if not both_done .done ():
222
210
log = self .log .warning if count % 10 == 0 else self .log .debug
223
211
log ("Nudge: attempt %s on kernel %s" % (count , self .kernel_id ))
224
- self .session .send (shell_channel , "kernel_info_request" )
212
+ self .session .send (control_channel , "kernel_info_request" )
225
213
nonlocal nudge_handle
226
214
nudge_handle = loop .call_later (0.5 , nudge , count )
227
215
0 commit comments