Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cleanup channel names to match function not socket

closes gh-178
  • Loading branch information...
commit 426248cb0978272da717e64645da3e0bd43c2946 1 parent b9c850d
Min RK authored
8 IPython/frontend/qt/base_frontend_mixin.py
@@ -30,8 +30,8 @@ def _set_kernel_manager(self, kernel_manager):
30 30
31 31 # Disconnect the old kernel manager's channels.
32 32 old_manager.sub_channel.message_received.disconnect(self._dispatch)
33   - old_manager.xreq_channel.message_received.disconnect(self._dispatch)
34   - old_manager.rep_channel.message_received.disconnect(self._dispatch)
  33 + old_manager.shell_channel.message_received.disconnect(self._dispatch)
  34 + old_manager.stdin_channel.message_received.disconnect(self._dispatch)
35 35 old_manager.hb_channel.kernel_died.disconnect(
36 36 self._handle_kernel_died)
37 37
@@ -50,8 +50,8 @@ def _set_kernel_manager(self, kernel_manager):
50 50
51 51 # Connect the new kernel manager's channels.
52 52 kernel_manager.sub_channel.message_received.connect(self._dispatch)
53   - kernel_manager.xreq_channel.message_received.connect(self._dispatch)
54   - kernel_manager.rep_channel.message_received.connect(self._dispatch)
  53 + kernel_manager.shell_channel.message_received.connect(self._dispatch)
  54 + kernel_manager.stdin_channel.message_received.connect(self._dispatch)
55 55 kernel_manager.hb_channel.kernel_died.connect(self._handle_kernel_died)
56 56
57 57 # Handle the case where the kernel manager started channels before
8 IPython/frontend/qt/console/frontend_widget.py
@@ -184,7 +184,7 @@ def _execute(self, source, hidden):
184 184
185 185 See parent class :meth:`execute` docstring for full details.
186 186 """
187   - msg_id = self.kernel_manager.xreq_channel.execute(source, hidden)
  187 + msg_id = self.kernel_manager.shell_channel.execute(source, hidden)
188 188 self._request_info['execute'] = self._ExecutionRequest(msg_id, 'user')
189 189 self._hidden = hidden
190 190 if not hidden:
@@ -330,7 +330,7 @@ def _handle_input_request(self, msg):
330 330 self.kernel_manager.sub_channel.flush()
331 331
332 332 def callback(line):
333   - self.kernel_manager.rep_channel.input(line)
  333 + self.kernel_manager.stdin_channel.input(line)
334 334 self._readline(msg['content']['prompt'], callback=callback)
335 335
336 336 def _handle_kernel_died(self, since_last_heartbeat):
@@ -518,7 +518,7 @@ def _call_tip(self):
518 518
519 519 # Send the metadata request to the kernel
520 520 name = '.'.join(context)
521   - msg_id = self.kernel_manager.xreq_channel.object_info(name)
  521 + msg_id = self.kernel_manager.shell_channel.object_info(name)
522 522 pos = self._get_cursor().position()
523 523 self._request_info['call_tip'] = self._CallTipRequest(msg_id, pos)
524 524 return True
@@ -529,7 +529,7 @@ def _complete(self):
529 529 context = self._get_context()
530 530 if context:
531 531 # Send the completion request to the kernel
532   - msg_id = self.kernel_manager.xreq_channel.complete(
  532 + msg_id = self.kernel_manager.shell_channel.complete(
533 533 '.'.join(context), # text
534 534 self._get_input_buffer_cursor_line(), # line
535 535 self._get_input_buffer_cursor_column(), # cursor_pos
6 IPython/frontend/qt/console/ipython_widget.py
@@ -219,7 +219,7 @@ def _started_channels(self):
219 219 """ Reimplemented to make a history request.
220 220 """
221 221 super(IPythonWidget, self)._started_channels()
222   - self.kernel_manager.xreq_channel.history(hist_access_type='tail', n=1000)
  222 + self.kernel_manager.shell_channel.history(hist_access_type='tail', n=1000)
223 223
224 224 #---------------------------------------------------------------------------
225 225 # 'ConsoleWidget' public interface
@@ -261,7 +261,7 @@ def _complete(self):
261 261 text = ''
262 262
263 263 # Send the completion request to the kernel
264   - msg_id = self.kernel_manager.xreq_channel.complete(
  264 + msg_id = self.kernel_manager.shell_channel.complete(
265 265 text, # text
266 266 self._get_input_buffer_cursor_line(), # line
267 267 self._get_input_buffer_cursor_column(), # cursor_pos
@@ -312,7 +312,7 @@ def _show_interpreter_prompt(self, number=None):
312 312 """
313 313 # If a number was not specified, make a prompt number request.
314 314 if number is None:
315   - msg_id = self.kernel_manager.xreq_channel.execute('', silent=True)
  315 + msg_id = self.kernel_manager.shell_channel.execute('', silent=True)
316 316 info = self._ExecutionRequest(msg_id, 'prompt')
317 317 self._request_info['execute'] = info
318 318 return
4 IPython/frontend/qt/console/ipythonqt.py
@@ -257,9 +257,9 @@ def init_kernel_manager(self):
257 257
258 258 # Create a KernelManager and start a kernel.
259 259 self.kernel_manager = QtKernelManager(
260   - xreq_address=(self.ip, self.shell_port),
  260 + shell_address=(self.ip, self.shell_port),
261 261 sub_address=(self.ip, self.iopub_port),
262   - rep_address=(self.ip, self.stdin_port),
  262 + stdin_address=(self.ip, self.stdin_port),
263 263 hb_address=(self.ip, self.hb_port)
264 264 )
265 265 # start the kernel
32 IPython/frontend/qt/kernelmanager.py
@@ -7,7 +7,7 @@
7 7 # IPython imports.
8 8 from IPython.utils.traitlets import Type
9 9 from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \
10   - XReqSocketChannel, RepSocketChannel, HBSocketChannel
  10 + ShellSocketChannel, StdInSocketChannel, HBSocketChannel
11 11 from util import MetaQObjectHasTraits, SuperQObject
12 12
13 13
@@ -20,7 +20,7 @@ class SocketChannelQObject(SuperQObject):
20 20 stopped = QtCore.Signal()
21 21
22 22 #---------------------------------------------------------------------------
23   - # 'ZmqSocketChannel' interface
  23 + # 'ZMQSocketChannel' interface
24 24 #---------------------------------------------------------------------------
25 25
26 26 def start(self):
@@ -36,7 +36,7 @@ def stop(self):
36 36 self.stopped.emit()
37 37
38 38
39   -class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel):
  39 +class QtShellSocketChannel(SocketChannelQObject, ShellSocketChannel):
40 40
41 41 # Emitted when any message is received.
42 42 message_received = QtCore.Signal(object)
@@ -56,7 +56,7 @@ class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel):
56 56 _handlers_called = False
57 57
58 58 #---------------------------------------------------------------------------
59   - # 'XReqSocketChannel' interface
  59 + # 'ShellSocketChannel' interface
60 60 #---------------------------------------------------------------------------
61 61
62 62 def call_handlers(self, msg):
@@ -76,7 +76,7 @@ def call_handlers(self, msg):
76 76 self._handlers_called = True
77 77
78 78 #---------------------------------------------------------------------------
79   - # 'QtXReqSocketChannel' interface
  79 + # 'QtShellSocketChannel' interface
80 80 #---------------------------------------------------------------------------
81 81
82 82 def reset_first_reply(self):
@@ -136,7 +136,7 @@ def flush(self):
136 136 QtCore.QCoreApplication.instance().processEvents()
137 137
138 138
139   -class QtRepSocketChannel(SocketChannelQObject, RepSocketChannel):
  139 +class QtStdInSocketChannel(SocketChannelQObject, StdInSocketChannel):
140 140
141 141 # Emitted when any message is received.
142 142 message_received = QtCore.Signal(object)
@@ -145,7 +145,7 @@ class QtRepSocketChannel(SocketChannelQObject, RepSocketChannel):
145 145 input_requested = QtCore.Signal(object)
146 146
147 147 #---------------------------------------------------------------------------
148   - # 'RepSocketChannel' interface
  148 + # 'StdInSocketChannel' interface
149 149 #---------------------------------------------------------------------------
150 150
151 151 def call_handlers(self, msg):
@@ -190,8 +190,8 @@ class QtKernelManager(KernelManager, SuperQObject):
190 190
191 191 # Use Qt-specific channel classes that emit signals.
192 192 sub_channel_class = Type(QtSubSocketChannel)
193   - xreq_channel_class = Type(QtXReqSocketChannel)
194   - rep_channel_class = Type(QtRepSocketChannel)
  193 + shell_channel_class = Type(QtShellSocketChannel)
  194 + stdin_channel_class = Type(QtStdInSocketChannel)
195 195 hb_channel_class = Type(QtHBSocketChannel)
196 196
197 197 #---------------------------------------------------------------------------
@@ -203,8 +203,8 @@ class QtKernelManager(KernelManager, SuperQObject):
203 203 def start_kernel(self, *args, **kw):
204 204 """ Reimplemented for proper heartbeat management.
205 205 """
206   - if self._xreq_channel is not None:
207   - self._xreq_channel.reset_first_reply()
  206 + if self._shell_channel is not None:
  207 + self._shell_channel.reset_first_reply()
208 208 super(QtKernelManager, self).start_kernel(*args, **kw)
209 209
210 210 #------ Channel management -------------------------------------------------
@@ -222,13 +222,13 @@ def stop_channels(self):
222 222 self.stopped_channels.emit()
223 223
224 224 @property
225   - def xreq_channel(self):
  225 + def shell_channel(self):
226 226 """ Reimplemented for proper heartbeat management.
227 227 """
228   - if self._xreq_channel is None:
229   - self._xreq_channel = super(QtKernelManager, self).xreq_channel
230   - self._xreq_channel.first_reply.connect(self._first_reply)
231   - return self._xreq_channel
  228 + if self._shell_channel is None:
  229 + self._shell_channel = super(QtKernelManager, self).shell_channel
  230 + self._shell_channel.first_reply.connect(self._first_reply)
  231 + return self._shell_channel
232 232
233 233 #---------------------------------------------------------------------------
234 234 # Protected interface
16 IPython/zmq/blockingkernelmanager.py
@@ -21,8 +21,8 @@
21 21 from IPython.utils import io
22 22 from IPython.utils.traitlets import Type
23 23
24   -from .kernelmanager import (KernelManager, SubSocketChannel,
25   - XReqSocketChannel, RepSocketChannel, HBSocketChannel)
  24 +from .kernelmanager import (KernelManager, SubSocketChannel, HBSocketChannel,
  25 + ShellSocketChannel, StdInSocketChannel)
26 26
27 27 #-----------------------------------------------------------------------------
28 28 # Functions and classes
@@ -61,15 +61,15 @@ def get_msgs(self):
61 61 return msgs
62 62
63 63
64   -class BlockingXReqSocketChannel(XReqSocketChannel):
  64 +class BlockingShellSocketChannel(ShellSocketChannel):
65 65
66 66 def __init__(self, context, session, address=None):
67   - super(BlockingXReqSocketChannel, self).__init__(context, session,
  67 + super(BlockingShellSocketChannel, self).__init__(context, session,
68 68 address)
69 69 self._in_queue = Queue()
70 70
71 71 def call_handlers(self, msg):
72   - #io.rprint('[[XReq]]', msg) # dbg
  72 + #io.rprint('[[Shell]]', msg) # dbg
73 73 self._in_queue.put(msg)
74 74
75 75 def msg_ready(self):
@@ -94,7 +94,7 @@ def get_msgs(self):
94 94 return msgs
95 95
96 96
97   -class BlockingRepSocketChannel(RepSocketChannel):
  97 +class BlockingStdInSocketChannel(StdInSocketChannel):
98 98
99 99 def call_handlers(self, msg):
100 100 #io.rprint('[[Rep]]', msg) # dbg
@@ -114,8 +114,8 @@ def call_handlers(self, since_last_heartbeat):
114 114 class BlockingKernelManager(KernelManager):
115 115
116 116 # The classes to use for the various channels.
117   - xreq_channel_class = Type(BlockingXReqSocketChannel)
  117 + shell_channel_class = Type(BlockingShellSocketChannel)
118 118 sub_channel_class = Type(BlockingSubSocketChannel)
119   - rep_channel_class = Type(BlockingRepSocketChannel)
  119 + stdin_channel_class = Type(BlockingStdInSocketChannel)
120 120 hb_channel_class = Type(BlockingHBSocketChannel)
121 121
88 IPython/zmq/kernelmanager.py
@@ -76,7 +76,7 @@ def validate_string_dict(dct):
76 76 # ZMQ Socket Channel classes
77 77 #-----------------------------------------------------------------------------
78 78
79   -class ZmqSocketChannel(Thread):
  79 +class ZMQSocketChannel(Thread):
80 80 """The base class for the channels that use ZMQ sockets.
81 81 """
82 82 context = None
@@ -98,7 +98,7 @@ def __init__(self, context, session, address):
98 98 address : tuple
99 99 Standard (ip, port) tuple that the kernel is listening on.
100 100 """
101   - super(ZmqSocketChannel, self).__init__()
  101 + super(ZMQSocketChannel, self).__init__()
102 102 self.daemon = True
103 103
104 104 self.context = context
@@ -159,14 +159,14 @@ def drop_io_state_callback():
159 159 self.ioloop.add_callback(drop_io_state_callback)
160 160
161 161
162   -class XReqSocketChannel(ZmqSocketChannel):
  162 +class ShellSocketChannel(ZMQSocketChannel):
163 163 """The XREQ channel for issues request/replies to the kernel.
164 164 """
165 165
166 166 command_queue = None
167 167
168 168 def __init__(self, context, session, address):
169   - super(XReqSocketChannel, self).__init__(context, session, address)
  169 + super(ShellSocketChannel, self).__init__(context, session, address)
170 170 self.command_queue = Queue()
171 171 self.ioloop = ioloop.IOLoop()
172 172
@@ -182,7 +182,7 @@ def run(self):
182 182
183 183 def stop(self):
184 184 self.ioloop.stop()
185   - super(XReqSocketChannel, self).stop()
  185 + super(ShellSocketChannel, self).stop()
186 186
187 187 def call_handlers(self, msg):
188 188 """This method is called in the ioloop thread when a message arrives.
@@ -368,7 +368,7 @@ def _queue_request(self, msg):
368 368 self.add_io_state(POLLOUT)
369 369
370 370
371   -class SubSocketChannel(ZmqSocketChannel):
  371 +class SubSocketChannel(ZMQSocketChannel):
372 372 """The SUB channel which listens for messages that the kernel publishes.
373 373 """
374 374
@@ -455,13 +455,13 @@ def _flush(self):
455 455 self._flushed = True
456 456
457 457
458   -class RepSocketChannel(ZmqSocketChannel):
  458 +class StdInSocketChannel(ZMQSocketChannel):
459 459 """A reply channel to handle raw_input requests that the kernel makes."""
460 460
461 461 msg_queue = None
462 462
463 463 def __init__(self, context, session, address):
464   - super(RepSocketChannel, self).__init__(context, session, address)
  464 + super(StdInSocketChannel, self).__init__(context, session, address)
465 465 self.ioloop = ioloop.IOLoop()
466 466 self.msg_queue = Queue()
467 467
@@ -477,7 +477,7 @@ def run(self):
477 477
478 478 def stop(self):
479 479 self.ioloop.stop()
480   - super(RepSocketChannel, self).stop()
  480 + super(StdInSocketChannel, self).stop()
481 481
482 482 def call_handlers(self, msg):
483 483 """This method is called in the ioloop thread when a message arrives.
@@ -526,7 +526,7 @@ def _queue_reply(self, msg):
526 526 self.add_io_state(POLLOUT)
527 527
528 528
529   -class HBSocketChannel(ZmqSocketChannel):
  529 +class HBSocketChannel(ZMQSocketChannel):
530 530 """The heartbeat channel which monitors the kernel heartbeat.
531 531
532 532 Note that the heartbeat channel is paused by default. As long as you start
@@ -663,22 +663,22 @@ class KernelManager(HasTraits):
663 663 kernel = Instance(Popen)
664 664
665 665 # The addresses for the communication channels.
666   - xreq_address = TCPAddress((LOCALHOST, 0))
  666 + shell_address = TCPAddress((LOCALHOST, 0))
667 667 sub_address = TCPAddress((LOCALHOST, 0))
668   - rep_address = TCPAddress((LOCALHOST, 0))
  668 + stdin_address = TCPAddress((LOCALHOST, 0))
669 669 hb_address = TCPAddress((LOCALHOST, 0))
670 670
671 671 # The classes to use for the various channels.
672   - xreq_channel_class = Type(XReqSocketChannel)
  672 + shell_channel_class = Type(ShellSocketChannel)
673 673 sub_channel_class = Type(SubSocketChannel)
674   - rep_channel_class = Type(RepSocketChannel)
  674 + stdin_channel_class = Type(StdInSocketChannel)
675 675 hb_channel_class = Type(HBSocketChannel)
676 676
677 677 # Protected traits.
678 678 _launch_args = Any
679   - _xreq_channel = Any
  679 + _shell_channel = Any
680 680 _sub_channel = Any
681   - _rep_channel = Any
  681 + _stdin_channel = Any
682 682 _hb_channel = Any
683 683
684 684 def __init__(self, **kwargs):
@@ -690,7 +690,7 @@ def __init__(self, **kwargs):
690 690 # Channel management methods:
691 691 #--------------------------------------------------------------------------
692 692
693   - def start_channels(self, xreq=True, sub=True, rep=True, hb=True):
  693 + def start_channels(self, shell=True, sub=True, stdin=True, hb=True):
694 694 """Starts the channels for this kernel.
695 695
696 696 This will create the channels if they do not exist and then start
@@ -698,32 +698,32 @@ def start_channels(self, xreq=True, sub=True, rep=True, hb=True):
698 698 must first call :method:`start_kernel`. If the channels have been
699 699 stopped and you call this, :class:`RuntimeError` will be raised.
700 700 """
701   - if xreq:
702   - self.xreq_channel.start()
  701 + if shell:
  702 + self.shell_channel.start()
703 703 if sub:
704 704 self.sub_channel.start()
705   - if rep:
706   - self.rep_channel.start()
  705 + if stdin:
  706 + self.stdin_channel.start()
707 707 if hb:
708 708 self.hb_channel.start()
709 709
710 710 def stop_channels(self):
711 711 """Stops all the running channels for this kernel.
712 712 """
713   - if self.xreq_channel.is_alive():
714   - self.xreq_channel.stop()
  713 + if self.shell_channel.is_alive():
  714 + self.shell_channel.stop()
715 715 if self.sub_channel.is_alive():
716 716 self.sub_channel.stop()
717   - if self.rep_channel.is_alive():
718   - self.rep_channel.stop()
  717 + if self.stdin_channel.is_alive():
  718 + self.stdin_channel.stop()
719 719 if self.hb_channel.is_alive():
720 720 self.hb_channel.stop()
721 721
722 722 @property
723 723 def channels_running(self):
724 724 """Are any of the channels created and running?"""
725   - return (self.xreq_channel.is_alive() or self.sub_channel.is_alive() or
726   - self.rep_channel.is_alive() or self.hb_channel.is_alive())
  725 + return (self.shell_channel.is_alive() or self.sub_channel.is_alive() or
  726 + self.stdin_channel.is_alive() or self.hb_channel.is_alive())
727 727
728 728 #--------------------------------------------------------------------------
729 729 # Kernel process management methods:
@@ -743,9 +743,9 @@ def start_kernel(self, **kw):
743 743 **kw : optional
744 744 See respective options for IPython and Python kernels.
745 745 """
746   - xreq, sub, rep, hb = self.xreq_address, self.sub_address, \
747   - self.rep_address, self.hb_address
748   - if xreq[0] not in LOCAL_IPS or sub[0] not in LOCAL_IPS or \
  746 + shell, sub, stdin, hb = self.shell_address, self.sub_address, \
  747 + self.stdin_address, self.hb_address
  748 + if shell[0] not in LOCAL_IPS or sub[0] not in LOCAL_IPS or \
749 749 rep[0] not in LOCAL_IPS or hb[0] not in LOCAL_IPS:
750 750 raise RuntimeError("Can only launch a kernel on a local interface. "
751 751 "Make sure that the '*_address' attributes are "
@@ -759,11 +759,11 @@ def start_kernel(self, **kw):
759 759 else:
760 760 from pykernel import launch_kernel
761 761 self.kernel, xrep, pub, req, _hb = launch_kernel(
762   - shell_port=xreq[1], iopub_port=sub[1],
  762 + shell_port=shell[1], iopub_port=sub[1],
763 763 stdin_port=rep[1], hb_port=hb[1], **kw)
764   - self.xreq_address = (xreq[0], xrep)
  764 + self.shell_address = (shell[0], xrep)
765 765 self.sub_address = (sub[0], pub)
766   - self.rep_address = (rep[0], req)
  766 + self.stdin_address = (stdin[0], req)
767 767 self.hb_address = (hb[0], _hb)
768 768
769 769 def shutdown_kernel(self, restart=False):
@@ -782,7 +782,7 @@ def shutdown_kernel(self, restart=False):
782 782 # Don't send any additional kernel kill messages immediately, to give
783 783 # the kernel a chance to properly execute shutdown actions. Wait for at
784 784 # most 1s, checking every 0.1s.
785   - self.xreq_channel.shutdown(restart=restart)
  785 + self.shell_channel.shutdown(restart=restart)
786 786 for i in range(10):
787 787 if self.is_alive:
788 788 time.sleep(0.1)
@@ -908,13 +908,13 @@ def is_alive(self):
908 908 #--------------------------------------------------------------------------
909 909
910 910 @property
911   - def xreq_channel(self):
  911 + def shell_channel(self):
912 912 """Get the REQ socket channel object to make requests of the kernel."""
913   - if self._xreq_channel is None:
914   - self._xreq_channel = self.xreq_channel_class(self.context,
  913 + if self._shell_channel is None:
  914 + self._shell_channel = self.shell_channel_class(self.context,
915 915 self.session,
916   - self.xreq_address)
917   - return self._xreq_channel
  916 + self.shell_address)
  917 + return self._shell_channel
918 918
919 919 @property
920 920 def sub_channel(self):
@@ -926,13 +926,13 @@ def sub_channel(self):
926 926 return self._sub_channel
927 927
928 928 @property
929   - def rep_channel(self):
  929 + def stdin_channel(self):
930 930 """Get the REP socket channel object to handle stdin (raw_input)."""
931   - if self._rep_channel is None:
932   - self._rep_channel = self.rep_channel_class(self.context,
  931 + if self._stdin_channel is None:
  932 + self._stdin_channel = self.stdin_channel_class(self.context,
933 933 self.session,
934   - self.rep_address)
935   - return self._rep_channel
  934 + self.stdin_address)
  935 + return self._stdin_channel
936 936
937 937 @property
938 938 def hb_channel(self):
4 IPython/zmq/tests/test_message_spec.py
@@ -35,6 +35,6 @@ def teardown():
35 35 # Actual tests
36 36
37 37 def test_execute():
38   - KM.xreq_channel.execute(code='x=1')
39   - KM.xreq_channel.execute(code='print 1')
  38 + KM.shell_channel.execute(code='x=1')
  39 + KM.shell_channel.execute(code='print 1')
40 40

0 comments on commit 426248c

Please sign in to comment.
Something went wrong with that request. Please try again.