##// END OF EJS Templates
Use messaging methods on kernel client instead of channel objects
Thomas Kluyver -
Show More
@@ -61,7 +61,7 b' class InProcessKernelTestCase(unittest.TestCase):'
61
61
62 kc = BlockingInProcessKernelClient(kernel=kernel)
62 kc = BlockingInProcessKernelClient(kernel=kernel)
63 kernel.frontends.append(kc)
63 kernel.frontends.append(kc)
64 kc.shell_channel.execute('print("bar")')
64 kc.execute('print("bar")')
65 msg = get_stream_message(kc)
65 msg = get_stream_message(kc)
66 self.assertEqual(msg['content']['text'], 'bar\n')
66 self.assertEqual(msg['content']['text'], 'bar\n')
67
67
@@ -463,7 +463,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
463 self.kernel_client.iopub_channel.flush()
463 self.kernel_client.iopub_channel.flush()
464
464
465 def callback(line):
465 def callback(line):
466 self.kernel_client.stdin_channel.input(line)
466 self.kernel_client.input(line)
467 if self._reading:
467 if self._reading:
468 self.log.debug("Got second input request, assuming first was interrupted.")
468 self.log.debug("Got second input request, assuming first was interrupted.")
469 self._reading = False
469 self._reading = False
@@ -225,7 +225,7 b' class HistoryConsoleWidget(ConsoleWidget):'
225 return self._history[-n:]
225 return self._history[-n:]
226
226
227 def _request_update_session_history_length(self):
227 def _request_update_session_history_length(self):
228 msg_id = self.kernel_client.shell_channel.execute('',
228 msg_id = self.kernel_client.execute('',
229 silent=True,
229 silent=True,
230 user_expressions={
230 user_expressions={
231 'hlen':'len(get_ipython().history_manager.input_hist_raw)',
231 'hlen':'len(get_ipython().history_manager.input_hist_raw)',
@@ -203,7 +203,7 b' class IPythonWidget(FrontendWidget):'
203 self._retrying_history_request = True
203 self._retrying_history_request = True
204 # wait out the kernel's queue flush, which is currently timed at 0.1s
204 # wait out the kernel's queue flush, which is currently timed at 0.1s
205 time.sleep(0.25)
205 time.sleep(0.25)
206 self.kernel_client.shell_channel.history(hist_access_type='tail',n=1000)
206 self.kernel_client.history(hist_access_type='tail',n=1000)
207 else:
207 else:
208 self._retrying_history_request = False
208 self._retrying_history_request = False
209 return
209 return
@@ -296,12 +296,11 b' class IPythonWidget(FrontendWidget):'
296 # The reply will trigger %guiref load provided language=='python'
296 # The reply will trigger %guiref load provided language=='python'
297 self.kernel_client.kernel_info()
297 self.kernel_client.kernel_info()
298
298
299 self.kernel_client.shell_channel.history(hist_access_type='tail',
299 self.kernel_client.history(hist_access_type='tail', n=1000)
300 n=1000)
301
300
302 def _load_guiref_magic(self):
301 def _load_guiref_magic(self):
303 """Load %guiref magic."""
302 """Load %guiref magic."""
304 self.kernel_client.shell_channel.execute('\n'.join([
303 self.kernel_client.execute('\n'.join([
305 "try:",
304 "try:",
306 " _usage",
305 " _usage",
307 "except:",
306 "except:",
@@ -385,7 +384,7 b' class IPythonWidget(FrontendWidget):'
385 """
384 """
386 # If a number was not specified, make a prompt number request.
385 # If a number was not specified, make a prompt number request.
387 if number is None:
386 if number is None:
388 msg_id = self.kernel_client.shell_channel.execute('', silent=True)
387 msg_id = self.kernel_client.execute('', silent=True)
389 info = self._ExecutionRequest(msg_id, 'prompt')
388 info = self._ExecutionRequest(msg_id, 'prompt')
390 self._request_info['execute'][msg_id] = info
389 self._request_info['execute'][msg_id] = info
391 return
390 return
@@ -36,7 +36,7 b' class ZMQCompleter(IPCompleter):'
36
36
37 # send completion request to kernel
37 # send completion request to kernel
38 # Give the kernel up to 0.5s to respond
38 # Give the kernel up to 0.5s to respond
39 msg_id = self.client.shell_channel.complete(
39 msg_id = self.client.complete(
40 code=line,
40 code=line,
41 cursor_pos=cursor_pos,
41 cursor_pos=cursor_pos,
42 )
42 )
@@ -157,8 +157,8 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
157 # flush stale replies, which could have been ignored, due to missed heartbeats
157 # flush stale replies, which could have been ignored, due to missed heartbeats
158 while self.client.shell_channel.msg_ready():
158 while self.client.shell_channel.msg_ready():
159 self.client.shell_channel.get_msg()
159 self.client.shell_channel.get_msg()
160 # shell_channel.execute takes 'hidden', which is the inverse of store_hist
160 # execute takes 'hidden', which is the inverse of store_hist
161 msg_id = self.client.shell_channel.execute(cell, not store_history)
161 msg_id = self.client.execute(cell, not store_history)
162
162
163 # first thing is wait for any side effects (output, stdin, etc.)
163 # first thing is wait for any side effects (output, stdin, etc.)
164 self._executing = True
164 self._executing = True
@@ -399,7 +399,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
399 # only send stdin reply if there *was not* another request
399 # only send stdin reply if there *was not* another request
400 # or execution finished while we were reading.
400 # or execution finished while we were reading.
401 if not (self.client.stdin_channel.msg_ready() or self.client.shell_channel.msg_ready()):
401 if not (self.client.stdin_channel.msg_ready() or self.client.shell_channel.msg_ready()):
402 self.client.stdin_channel.input(raw_data)
402 self.client.input(raw_data)
403
403
404 def mainloop(self, display_banner=False):
404 def mainloop(self, display_banner=False):
405 while True:
405 while True:
@@ -414,7 +414,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
414 # handling seems rather unpredictable...
414 # handling seems rather unpredictable...
415 self.write("\nKeyboardInterrupt in interact()\n")
415 self.write("\nKeyboardInterrupt in interact()\n")
416
416
417 self.client.shell_channel.shutdown()
417 self.client.shutdown()
418
418
419 def _banner1_default(self):
419 def _banner1_default(self):
420 return "IPython Console {version}\n".format(version=release.version)
420 return "IPython Console {version}\n".format(version=release.version)
General Comments 0
You need to be logged in to leave comments. Login now