Skip to content

Commit

Permalink
cleanup channel names to match function not socket
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Jun 20, 2011
1 parent 8b39375 commit 625fd57
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 85 deletions.
8 changes: 4 additions & 4 deletions IPython/frontend/qt/base_frontend_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def _set_kernel_manager(self, kernel_manager):

# Disconnect the old kernel manager's channels.
old_manager.sub_channel.message_received.disconnect(self._dispatch)
old_manager.xreq_channel.message_received.disconnect(self._dispatch)
old_manager.rep_channel.message_received.disconnect(self._dispatch)
old_manager.shell_channel.message_received.disconnect(self._dispatch)
old_manager.stdin_channel.message_received.disconnect(self._dispatch)
old_manager.hb_channel.kernel_died.disconnect(
self._handle_kernel_died)

Expand All @@ -50,8 +50,8 @@ def _set_kernel_manager(self, kernel_manager):

# Connect the new kernel manager's channels.
kernel_manager.sub_channel.message_received.connect(self._dispatch)
kernel_manager.xreq_channel.message_received.connect(self._dispatch)
kernel_manager.rep_channel.message_received.connect(self._dispatch)
kernel_manager.shell_channel.message_received.connect(self._dispatch)
kernel_manager.stdin_channel.message_received.connect(self._dispatch)
kernel_manager.hb_channel.kernel_died.connect(self._handle_kernel_died)

# Handle the case where the kernel manager started channels before
Expand Down
8 changes: 4 additions & 4 deletions IPython/frontend/qt/console/frontend_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _execute(self, source, hidden):
See parent class :meth:`execute` docstring for full details.
"""
msg_id = self.kernel_manager.xreq_channel.execute(source, hidden)
msg_id = self.kernel_manager.shell_channel.execute(source, hidden)
self._request_info['execute'] = self._ExecutionRequest(msg_id, 'user')
self._hidden = hidden
if not hidden:
Expand Down Expand Up @@ -330,7 +330,7 @@ def _handle_input_request(self, msg):
self.kernel_manager.sub_channel.flush()

def callback(line):
self.kernel_manager.rep_channel.input(line)
self.kernel_manager.stdin_channel.input(line)
self._readline(msg['content']['prompt'], callback=callback)

def _handle_kernel_died(self, since_last_heartbeat):
Expand Down Expand Up @@ -527,7 +527,7 @@ def _call_tip(self):

# Send the metadata request to the kernel
name = '.'.join(context)
msg_id = self.kernel_manager.xreq_channel.object_info(name)
msg_id = self.kernel_manager.shell_channel.object_info(name)
pos = self._get_cursor().position()
self._request_info['call_tip'] = self._CallTipRequest(msg_id, pos)
return True
Expand All @@ -538,7 +538,7 @@ def _complete(self):
context = self._get_context()
if context:
# Send the completion request to the kernel
msg_id = self.kernel_manager.xreq_channel.complete(
msg_id = self.kernel_manager.shell_channel.complete(
'.'.join(context), # text
self._get_input_buffer_cursor_line(), # line
self._get_input_buffer_cursor_column(), # cursor_pos
Expand Down
6 changes: 3 additions & 3 deletions IPython/frontend/qt/console/ipython_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _started_channels(self):
""" Reimplemented to make a history request.
"""
super(IPythonWidget, self)._started_channels()
self.kernel_manager.xreq_channel.history(hist_access_type='tail', n=1000)
self.kernel_manager.shell_channel.history(hist_access_type='tail', n=1000)

#---------------------------------------------------------------------------
# 'ConsoleWidget' public interface
Expand Down Expand Up @@ -264,7 +264,7 @@ def _complete(self):
text = ''

# Send the completion request to the kernel
msg_id = self.kernel_manager.xreq_channel.complete(
msg_id = self.kernel_manager.shell_channel.complete(
text, # text
self._get_input_buffer_cursor_line(), # line
self._get_input_buffer_cursor_column(), # cursor_pos
Expand Down Expand Up @@ -315,7 +315,7 @@ def _show_interpreter_prompt(self, number=None):
"""
# If a number was not specified, make a prompt number request.
if number is None:
msg_id = self.kernel_manager.xreq_channel.execute('', silent=True)
msg_id = self.kernel_manager.shell_channel.execute('', silent=True)
info = self._ExecutionRequest(msg_id, 'prompt')
self._request_info['execute'] = info
return
Expand Down
4 changes: 2 additions & 2 deletions IPython/frontend/qt/console/ipythonqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ def init_kernel_manager(self):

# Create a KernelManager and start a kernel.
self.kernel_manager = QtKernelManager(
xreq_address=(self.ip, self.shell_port),
shell_address=(self.ip, self.shell_port),
sub_address=(self.ip, self.iopub_port),
rep_address=(self.ip, self.stdin_port),
stdin_address=(self.ip, self.stdin_port),
hb_address=(self.ip, self.hb_port)
)
# start the kernel
Expand Down
32 changes: 16 additions & 16 deletions IPython/frontend/qt/kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# IPython imports.
from IPython.utils.traitlets import Type
from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \
XReqSocketChannel, RepSocketChannel, HBSocketChannel
ShellSocketChannel, StdInSocketChannel, HBSocketChannel
from util import MetaQObjectHasTraits, SuperQObject


Expand All @@ -20,7 +20,7 @@ class SocketChannelQObject(SuperQObject):
stopped = QtCore.Signal()

#---------------------------------------------------------------------------
# 'ZmqSocketChannel' interface
# 'ZMQSocketChannel' interface
#---------------------------------------------------------------------------

def start(self):
Expand All @@ -36,7 +36,7 @@ def stop(self):
self.stopped.emit()


class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel):
class QtShellSocketChannel(SocketChannelQObject, ShellSocketChannel):

# Emitted when any message is received.
message_received = QtCore.Signal(object)
Expand All @@ -56,7 +56,7 @@ class QtXReqSocketChannel(SocketChannelQObject, XReqSocketChannel):
_handlers_called = False

#---------------------------------------------------------------------------
# 'XReqSocketChannel' interface
# 'ShellSocketChannel' interface
#---------------------------------------------------------------------------

def call_handlers(self, msg):
Expand All @@ -76,7 +76,7 @@ def call_handlers(self, msg):
self._handlers_called = True

#---------------------------------------------------------------------------
# 'QtXReqSocketChannel' interface
# 'QtShellSocketChannel' interface
#---------------------------------------------------------------------------

def reset_first_reply(self):
Expand Down Expand Up @@ -136,7 +136,7 @@ def flush(self):
QtCore.QCoreApplication.instance().processEvents()


class QtRepSocketChannel(SocketChannelQObject, RepSocketChannel):
class QtStdInSocketChannel(SocketChannelQObject, StdInSocketChannel):

# Emitted when any message is received.
message_received = QtCore.Signal(object)
Expand All @@ -145,7 +145,7 @@ class QtRepSocketChannel(SocketChannelQObject, RepSocketChannel):
input_requested = QtCore.Signal(object)

#---------------------------------------------------------------------------
# 'RepSocketChannel' interface
# 'StdInSocketChannel' interface
#---------------------------------------------------------------------------

def call_handlers(self, msg):
Expand Down Expand Up @@ -190,8 +190,8 @@ class QtKernelManager(KernelManager, SuperQObject):

# Use Qt-specific channel classes that emit signals.
sub_channel_class = Type(QtSubSocketChannel)
xreq_channel_class = Type(QtXReqSocketChannel)
rep_channel_class = Type(QtRepSocketChannel)
shell_channel_class = Type(QtShellSocketChannel)
stdin_channel_class = Type(QtStdInSocketChannel)
hb_channel_class = Type(QtHBSocketChannel)

#---------------------------------------------------------------------------
Expand All @@ -203,8 +203,8 @@ class QtKernelManager(KernelManager, SuperQObject):
def start_kernel(self, *args, **kw):
""" Reimplemented for proper heartbeat management.
"""
if self._xreq_channel is not None:
self._xreq_channel.reset_first_reply()
if self._shell_channel is not None:
self._shell_channel.reset_first_reply()
super(QtKernelManager, self).start_kernel(*args, **kw)

#------ Channel management -------------------------------------------------
Expand All @@ -222,13 +222,13 @@ def stop_channels(self):
self.stopped_channels.emit()

@property
def xreq_channel(self):
def shell_channel(self):
""" Reimplemented for proper heartbeat management.
"""
if self._xreq_channel is None:
self._xreq_channel = super(QtKernelManager, self).xreq_channel
self._xreq_channel.first_reply.connect(self._first_reply)
return self._xreq_channel
if self._shell_channel is None:
self._shell_channel = super(QtKernelManager, self).shell_channel
self._shell_channel.first_reply.connect(self._first_reply)
return self._shell_channel

#---------------------------------------------------------------------------
# Protected interface
Expand Down
16 changes: 8 additions & 8 deletions IPython/zmq/blockingkernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from IPython.utils import io
from IPython.utils.traitlets import Type

from .kernelmanager import (KernelManager, SubSocketChannel,
XReqSocketChannel, RepSocketChannel, HBSocketChannel)
from .kernelmanager import (KernelManager, SubSocketChannel, HBSocketChannel,
ShellSocketChannel, StdInSocketChannel)

#-----------------------------------------------------------------------------
# Functions and classes
Expand Down Expand Up @@ -61,15 +61,15 @@ def get_msgs(self):
return msgs


class BlockingXReqSocketChannel(XReqSocketChannel):
class BlockingShellSocketChannel(ShellSocketChannel):

def __init__(self, context, session, address=None):
super(BlockingXReqSocketChannel, self).__init__(context, session,
super(BlockingShellSocketChannel, self).__init__(context, session,
address)
self._in_queue = Queue()

def call_handlers(self, msg):
#io.rprint('[[XReq]]', msg) # dbg
#io.rprint('[[Shell]]', msg) # dbg
self._in_queue.put(msg)

def msg_ready(self):
Expand All @@ -94,7 +94,7 @@ def get_msgs(self):
return msgs


class BlockingRepSocketChannel(RepSocketChannel):
class BlockingStdInSocketChannel(StdInSocketChannel):

def call_handlers(self, msg):
#io.rprint('[[Rep]]', msg) # dbg
Expand All @@ -114,8 +114,8 @@ def call_handlers(self, since_last_heartbeat):
class BlockingKernelManager(KernelManager):

# The classes to use for the various channels.
xreq_channel_class = Type(BlockingXReqSocketChannel)
shell_channel_class = Type(BlockingShellSocketChannel)
sub_channel_class = Type(BlockingSubSocketChannel)
rep_channel_class = Type(BlockingRepSocketChannel)
stdin_channel_class = Type(BlockingStdInSocketChannel)
hb_channel_class = Type(BlockingHBSocketChannel)

Loading

0 comments on commit 625fd57

Please sign in to comment.