Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions ipykernel/inprocess/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ipykernel.zmqshell import ZMQInteractiveShell

from .socket import DummySocket
from ..iostream import OutStream, BackgroundSocket, IOPubThread

#-----------------------------------------------------------------------------
# Main kernel class
Expand Down Expand Up @@ -49,13 +50,23 @@ class InProcessKernel(IPythonKernel):
shell_class = Type(allow_none=True)
shell_streams = List()
control_stream = Any()
iopub_socket = Instance(DummySocket, ())
_underlying_iopub_socket = Instance(DummySocket, ())
iopub_thread = Instance(IOPubThread)
def _iopub_thread_default(self):
thread = IOPubThread(self._underlying_iopub_socket)
thread.start()
return thread

iopub_socket = Instance(BackgroundSocket)
def _iopub_socket_default(self):
return self.iopub_thread.background_socket

stdin_socket = Instance(DummySocket, ())

def __init__(self, **traits):
super(InProcessKernel, self).__init__(**traits)

self.iopub_socket.on_trait_change(self._io_dispatch, 'message_sent')
self._underlying_iopub_socket.on_trait_change(self._io_dispatch, 'message_sent')
self.shell.kernel = self

def execute_request(self, stream, ident, parent):
Expand Down Expand Up @@ -128,12 +139,10 @@ def _shell_class_default(self):
return InProcessInteractiveShell

def _stdout_default(self):
from ipykernel.iostream import OutStream
return OutStream(self.session, self.iopub_socket, u'stdout', pipe=False)
return OutStream(self.session, self.iopub_thread, u'stdout')

def _stderr_default(self):
from ipykernel.iostream import OutStream
return OutStream(self.session, self.iopub_socket, u'stderr', pipe=False)
return OutStream(self.session, self.iopub_thread, u'stderr')

#-----------------------------------------------------------------------------
# Interactive shell subclass
Expand Down
Loading