##// END OF EJS Templates
REFACTOR: Terminology change: 'embedded' -> 'in-process'.
epatters -
Show More
@@ -0,0 +1,33 b''
1 """ Defines an in-process KernelManager with signals and slots.
2 """
3
4 # Local imports.
5 from IPython.inprocess.kernelmanager import \
6 ShellInProcessChannel, SubInProcessChannel, StdInInProcessChannel, \
7 HBInProcessChannel, InProcessKernelManager
8 from IPython.utils.traitlets import Type
9 from base_kernelmanager import QtShellChannelMixin, QtSubChannelMixin, \
10 QtStdInChannelMixin, QtHBChannelMixin, QtKernelManagerMixin
11
12
13 class QtShellInProcessChannel(QtShellChannelMixin, ShellInProcessChannel):
14 pass
15
16 class QtSubInProcessChannel(QtSubChannelMixin, SubInProcessChannel):
17 pass
18
19 class QtStdInInProcessChannel(QtStdInChannelMixin, StdInInProcessChannel):
20 pass
21
22 class QtHBInProcessChannel(QtHBChannelMixin, HBInProcessChannel):
23 pass
24
25
26 class QtInProcessKernelManager(QtKernelManagerMixin, InProcessKernelManager):
27 """ An in-process KernelManager with signals and slots.
28 """
29
30 sub_channel_class = Type(QtSubInProcessChannel)
31 shell_channel_class = Type(QtShellInProcessChannel)
32 stdin_channel_class = Type(QtStdInInProcessChannel)
33 hb_channel_class = Type(QtHBInProcessChannel)
@@ -34,7 +34,7 b' class ChannelQObject(SuperQObject):'
34 self.stopped.emit()
34 self.stopped.emit()
35
35
36 #---------------------------------------------------------------------------
36 #---------------------------------------------------------------------------
37 # EmbeddedChannel interface
37 # InProcessChannel interface
38 #---------------------------------------------------------------------------
38 #---------------------------------------------------------------------------
39
39
40 def call_handlers_later(self, *args, **kwds):
40 def call_handlers_later(self, *args, **kwds):
1 NO CONTENT: file renamed from IPython/embedded/__init__.py to IPython/inprocess/__init__.py
NO CONTENT: file renamed from IPython/embedded/__init__.py to IPython/inprocess/__init__.py
@@ -20,8 +20,8 b' from threading import Event'
20
20
21 # Local imports.
21 # Local imports.
22 from IPython.utils.traitlets import Type
22 from IPython.utils.traitlets import Type
23 from kernelmanager import EmbeddedKernelManager, ShellEmbeddedChannel, \
23 from kernelmanager import InProcessKernelManager, ShellInProcessChannel, \
24 SubEmbeddedChannel, StdInEmbeddedChannel
24 SubInProcessChannel, StdInInProcessChannel
25
25
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27 # Utility classes
27 # Utility classes
@@ -58,18 +58,18 b' class BlockingChannelMixin(object):'
58 # Blocking kernel manager
58 # Blocking kernel manager
59 #-----------------------------------------------------------------------------
59 #-----------------------------------------------------------------------------
60
60
61 class BlockingShellEmbeddedChannel(BlockingChannelMixin, ShellEmbeddedChannel):
61 class BlockingShellInProcessChannel(BlockingChannelMixin, ShellInProcessChannel):
62 pass
62 pass
63
63
64 class BlockingSubEmbeddedChannel(BlockingChannelMixin, SubEmbeddedChannel):
64 class BlockingSubInProcessChannel(BlockingChannelMixin, SubInProcessChannel):
65 pass
65 pass
66
66
67 class BlockingStdInEmbeddedChannel(BlockingChannelMixin, StdInEmbeddedChannel):
67 class BlockingStdInInProcessChannel(BlockingChannelMixin, StdInInProcessChannel):
68 pass
68 pass
69
69
70 class BlockingEmbeddedKernelManager(EmbeddedKernelManager):
70 class BlockingInProcessKernelManager(InProcessKernelManager):
71
71
72 # The classes to use for the various channels.
72 # The classes to use for the various channels.
73 shell_channel_class = Type(BlockingShellEmbeddedChannel)
73 shell_channel_class = Type(BlockingShellInProcessChannel)
74 sub_channel_class = Type(BlockingSubEmbeddedChannel)
74 sub_channel_class = Type(BlockingSubInProcessChannel)
75 stdin_channel_class = Type(BlockingStdInEmbeddedChannel)
75 stdin_channel_class = Type(BlockingStdInInProcessChannel)
@@ -1,4 +1,4 b''
1 """ An embedded (in-process) kernel. """
1 """ An in-process kernel. """
2
2
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (C) 2012 The IPython Development Team
4 # Copyright (C) 2012 The IPython Development Team
@@ -17,7 +17,7 b' import logging'
17 import sys
17 import sys
18
18
19 # Local imports.
19 # Local imports.
20 from IPython.embedded.socket import DummySocket
20 from IPython.inprocess.socket import DummySocket
21 from IPython.utils.jsonutil import json_clean
21 from IPython.utils.jsonutil import json_clean
22 from IPython.utils.traitlets import Any, Instance, List
22 from IPython.utils.traitlets import Any, Instance, List
23 from IPython.zmq.ipkernel import Kernel
23 from IPython.zmq.ipkernel import Kernel
@@ -26,14 +26,14 b' from IPython.zmq.ipkernel import Kernel'
26 # Main kernel class
26 # Main kernel class
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28
28
29 class EmbeddedKernel(Kernel):
29 class InProcessKernel(Kernel):
30
30
31 #-------------------------------------------------------------------------
31 #-------------------------------------------------------------------------
32 # EmbeddedKernel interface
32 # InProcessKernel interface
33 #-------------------------------------------------------------------------
33 #-------------------------------------------------------------------------
34
34
35 frontends = List(
35 frontends = List(
36 Instance('IPython.embedded.kernelmanager.EmbeddedKernelManager'))
36 Instance('IPython.inprocess.kernelmanager.InProcessKernelManager'))
37
37
38 raw_input_str = Any()
38 raw_input_str = Any()
39 stdout = Any()
39 stdout = Any()
@@ -52,21 +52,21 b' class EmbeddedKernel(Kernel):'
52 # When an InteractiveShell is instantiated by our base class, it binds
52 # When an InteractiveShell is instantiated by our base class, it binds
53 # the current values of sys.stdout and sys.stderr.
53 # the current values of sys.stdout and sys.stderr.
54 with self._redirected_io():
54 with self._redirected_io():
55 super(EmbeddedKernel, self).__init__(**traits)
55 super(InProcessKernel, self).__init__(**traits)
56
56
57 self.iopub_socket.on_trait_change(self._io_dispatch, 'message_sent')
57 self.iopub_socket.on_trait_change(self._io_dispatch, 'message_sent')
58
58
59 def execute_request(self, stream, ident, parent):
59 def execute_request(self, stream, ident, parent):
60 """ Override for temporary IO redirection. """
60 """ Override for temporary IO redirection. """
61 with self._redirected_io():
61 with self._redirected_io():
62 super(EmbeddedKernel, self).execute_request(stream, ident, parent)
62 super(InProcessKernel, self).execute_request(stream, ident, parent)
63
63
64 def start(self):
64 def start(self):
65 """ Override registration of dispatchers for streams. """
65 """ Override registration of dispatchers for streams. """
66 self.shell.exit_now = False
66 self.shell.exit_now = False
67
67
68 def _abort_queue(self, stream):
68 def _abort_queue(self, stream):
69 """ The embedded kernel don't abort requests. """
69 """ The in-process kernel doesn't abort requests. """
70 pass
70 pass
71
71
72 def _raw_input(self, prompt, ident, parent):
72 def _raw_input(self, prompt, ident, parent):
@@ -1,4 +1,4 b''
1 """ A kernel manager for embedded (in-process) kernels. """
1 """ A kernel manager for in-process kernels. """
2
2
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (C) 2012 The IPython Development Team
4 # Copyright (C) 2012 The IPython Development Team
@@ -13,19 +13,19 b''
13
13
14 # Local imports.
14 # Local imports.
15 from IPython.config.loader import Config
15 from IPython.config.loader import Config
16 from IPython.embedded.socket import DummySocket
16 from IPython.inprocess.socket import DummySocket
17 from IPython.utils.traitlets import HasTraits, Any, Instance, Type
17 from IPython.utils.traitlets import HasTraits, Any, Instance, Type
18
18
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20 # Channel classes
20 # Channel classes
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22
22
23 class EmbeddedChannel(object):
23 class InProcessChannel(object):
24 """ Base class for embedded channels.
24 """ Base class for in-process channels.
25 """
25 """
26
26
27 def __init__(self, manager):
27 def __init__(self, manager):
28 super(EmbeddedChannel, self).__init__()
28 super(InProcessChannel, self).__init__()
29 self.manager = manager
29 self.manager = manager
30 self._is_alive = False
30 self._is_alive = False
31
31
@@ -50,7 +50,7 b' class EmbeddedChannel(object):'
50 raise NotImplementedError('call_handlers must be defined in a subclass.')
50 raise NotImplementedError('call_handlers must be defined in a subclass.')
51
51
52 #--------------------------------------------------------------------------
52 #--------------------------------------------------------------------------
53 # EmbeddedChannel interface
53 # InProcessChannel interface
54 #--------------------------------------------------------------------------
54 #--------------------------------------------------------------------------
55
55
56 def call_handlers_later(self, *args, **kwds):
56 def call_handlers_later(self, *args, **kwds):
@@ -71,7 +71,7 b' class EmbeddedChannel(object):'
71 raise NotImplementedError
71 raise NotImplementedError
72
72
73
73
74 class ShellEmbeddedChannel(EmbeddedChannel):
74 class ShellInProcessChannel(InProcessChannel):
75 """The DEALER channel for issues request/replies to the kernel.
75 """The DEALER channel for issues request/replies to the kernel.
76 """
76 """
77
77
@@ -215,10 +215,10 b' class ShellEmbeddedChannel(EmbeddedChannel):'
215 def shutdown(self, restart=False):
215 def shutdown(self, restart=False):
216 """ Request an immediate kernel shutdown.
216 """ Request an immediate kernel shutdown.
217
217
218 A dummy method for the embedded kernel.
218 A dummy method for the in-process kernel.
219 """
219 """
220 # FIXME: What to do here?
220 # FIXME: What to do here?
221 raise NotImplementedError('Shutdown not supported for embedded kernel')
221 raise NotImplementedError('Cannot shutdown in-process kernel')
222
222
223 #--------------------------------------------------------------------------
223 #--------------------------------------------------------------------------
224 # Protected interface
224 # Protected interface
@@ -240,19 +240,19 b' class ShellEmbeddedChannel(EmbeddedChannel):'
240 self.call_handlers_later(reply_msg)
240 self.call_handlers_later(reply_msg)
241
241
242
242
243 class SubEmbeddedChannel(EmbeddedChannel):
243 class SubInProcessChannel(InProcessChannel):
244 """The SUB channel which listens for messages that the kernel publishes.
244 """The SUB channel which listens for messages that the kernel publishes.
245 """
245 """
246
246
247 def flush(self, timeout=1.0):
247 def flush(self, timeout=1.0):
248 """ Immediately processes all pending messages on the SUB channel.
248 """ Immediately processes all pending messages on the SUB channel.
249
249
250 A dummy method for the embedded kernel.
250 A dummy method for the in-process kernel.
251 """
251 """
252 pass
252 pass
253
253
254
254
255 class StdInEmbeddedChannel(EmbeddedChannel):
255 class StdInInProcessChannel(InProcessChannel):
256 """ A reply channel to handle raw_input requests that the kernel makes. """
256 """ A reply channel to handle raw_input requests that the kernel makes. """
257
257
258 def input(self, string):
258 def input(self, string):
@@ -264,13 +264,13 b' class StdInEmbeddedChannel(EmbeddedChannel):'
264 kernel.raw_input_str = string
264 kernel.raw_input_str = string
265
265
266
266
267 class HBEmbeddedChannel(EmbeddedChannel):
267 class HBInProcessChannel(InProcessChannel):
268 """ A dummy heartbeat channel. """
268 """ A dummy heartbeat channel. """
269
269
270 time_to_dead = 3.0
270 time_to_dead = 3.0
271
271
272 def __init__(self, *args, **kwds):
272 def __init__(self, *args, **kwds):
273 super(HBEmbeddedChannel, self).__init__(*args, **kwds)
273 super(HBInProcessChannel, self).__init__(*args, **kwds)
274 self._pause = True
274 self._pause = True
275
275
276 def pause(self):
276 def pause(self):
@@ -290,8 +290,8 b' class HBEmbeddedChannel(EmbeddedChannel):'
290 # Main kernel manager class
290 # Main kernel manager class
291 #-----------------------------------------------------------------------------
291 #-----------------------------------------------------------------------------
292
292
293 class EmbeddedKernelManager(HasTraits):
293 class InProcessKernelManager(HasTraits):
294 """ A manager for an embedded kernel.
294 """ A manager for an in-process kernel.
295
295
296 This class implements most of the interface of
296 This class implements most of the interface of
297 ``IPython.zmq.kernelmanager.KernelManager`` and allows (asynchronous)
297 ``IPython.zmq.kernelmanager.KernelManager`` and allows (asynchronous)
@@ -307,13 +307,13 b' class EmbeddedKernelManager(HasTraits):'
307 return Session(config=self.config)
307 return Session(config=self.config)
308
308
309 # The kernel process with which the KernelManager is communicating.
309 # The kernel process with which the KernelManager is communicating.
310 kernel = Instance('IPython.embedded.ipkernel.EmbeddedKernel')
310 kernel = Instance('IPython.inprocess.ipkernel.InProcessKernel')
311
311
312 # The classes to use for the various channels.
312 # The classes to use for the various channels.
313 shell_channel_class = Type(ShellEmbeddedChannel)
313 shell_channel_class = Type(ShellInProcessChannel)
314 sub_channel_class = Type(SubEmbeddedChannel)
314 sub_channel_class = Type(SubInProcessChannel)
315 stdin_channel_class = Type(StdInEmbeddedChannel)
315 stdin_channel_class = Type(StdInInProcessChannel)
316 hb_channel_class = Type(HBEmbeddedChannel)
316 hb_channel_class = Type(HBInProcessChannel)
317
317
318 # Protected traits.
318 # Protected traits.
319 _shell_channel = Any
319 _shell_channel = Any
@@ -365,8 +365,8 b' class EmbeddedKernelManager(HasTraits):'
365 def start_kernel(self, **kwds):
365 def start_kernel(self, **kwds):
366 """ Starts a kernel process and configures the manager to use it.
366 """ Starts a kernel process and configures the manager to use it.
367 """
367 """
368 from IPython.embedded.ipkernel import EmbeddedKernel
368 from IPython.inprocess.ipkernel import InProcessKernel
369 self.kernel = EmbeddedKernel()
369 self.kernel = InProcessKernel()
370 self.kernel.frontends.append(self)
370 self.kernel.frontends.append(self)
371
371
372 def shutdown_kernel(self):
372 def shutdown_kernel(self):
@@ -398,11 +398,11 b' class EmbeddedKernelManager(HasTraits):'
398
398
399 def interrupt_kernel(self):
399 def interrupt_kernel(self):
400 """ Interrupts the kernel. """
400 """ Interrupts the kernel. """
401 raise NotImplementedError("Cannot interrupt embedded kernel.")
401 raise NotImplementedError("Cannot interrupt in-process kernel.")
402
402
403 def signal_kernel(self, signum):
403 def signal_kernel(self, signum):
404 """ Sends a signal to the kernel. """
404 """ Sends a signal to the kernel. """
405 raise NotImplementedError("Cannot signal embedded kernel.")
405 raise NotImplementedError("Cannot signal in-process kernel.")
406
406
407 @property
407 @property
408 def is_alive(self):
408 def is_alive(self):
1 NO CONTENT: file renamed from IPython/embedded/socket.py to IPython/inprocess/socket.py
NO CONTENT: file renamed from IPython/embedded/socket.py to IPython/inprocess/socket.py
@@ -14,7 +14,7 b' Useful for test suites and blocking terminal interfaces.'
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15
15
16 # Local imports.
16 # Local imports.
17 from IPython.embedded.blockingkernelmanager import BlockingChannelMixin
17 from IPython.inprocess.blockingkernelmanager import BlockingChannelMixin
18 from IPython.utils.traitlets import Type
18 from IPython.utils.traitlets import Type
19 from kernelmanager import KernelManager, SubSocketChannel, HBSocketChannel, \
19 from kernelmanager import KernelManager, SubSocketChannel, HBSocketChannel, \
20 ShellSocketChannel, StdInSocketChannel
20 ShellSocketChannel, StdInSocketChannel
@@ -13,7 +13,7 b''
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 from IPython.config import Configurable
15 from IPython.config import Configurable
16 from IPython.embedded.socket import SocketABC
16 from IPython.inprocess.socket import SocketABC
17 from IPython.utils.jsonutil import json_clean
17 from IPython.utils.jsonutil import json_clean
18 from IPython.utils.traitlets import Instance, Dict, CBytes
18 from IPython.utils.traitlets import Instance, Dict, CBytes
19 from IPython.zmq.serialize import serialize_object
19 from IPython.zmq.serialize import serialize_object
@@ -2,7 +2,7 b' import __builtin__'
2 import sys
2 import sys
3
3
4 from IPython.core.displayhook import DisplayHook
4 from IPython.core.displayhook import DisplayHook
5 from IPython.embedded.socket import SocketABC
5 from IPython.inprocess.socket import SocketABC
6 from IPython.utils.jsonutil import encode_images
6 from IPython.utils.jsonutil import encode_images
7 from IPython.utils.traitlets import Instance, Dict
7 from IPython.utils.traitlets import Instance, Dict
8 from session import extract_header, Session
8 from session import extract_header, Session
@@ -34,7 +34,7 b' from IPython.core.error import UsageError'
34 from IPython.core.magics import MacroToEdit, CodeMagics
34 from IPython.core.magics import MacroToEdit, CodeMagics
35 from IPython.core.magic import magics_class, line_magic, Magics
35 from IPython.core.magic import magics_class, line_magic, Magics
36 from IPython.core.payloadpage import install_payload_page
36 from IPython.core.payloadpage import install_payload_page
37 from IPython.embedded.socket import SocketABC
37 from IPython.inprocess.socket import SocketABC
38 from IPython.lib.kernel import (
38 from IPython.lib.kernel import (
39 get_connection_file, get_connection_info, connect_qtconsole
39 get_connection_file, get_connection_info, connect_qtconsole
40 )
40 )
@@ -1,6 +1,6 b''
1 from IPython.embedded.ipkernel import EmbeddedKernel
1 from IPython.inprocess.ipkernel import InProcessKernel
2 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
2 from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
3 from IPython.frontend.qt.embedded_kernelmanager import QtEmbeddedKernelManager
3 from IPython.frontend.qt.inprocess_kernelmanager import QtInProcessKernelManager
4 from IPython.lib import guisupport
4 from IPython.lib import guisupport
5
5
6
6
@@ -8,11 +8,11 b' def main():'
8 app = guisupport.get_app_qt4()
8 app = guisupport.get_app_qt4()
9
9
10 # Create a kernel and populate the namespace.
10 # Create a kernel and populate the namespace.
11 kernel = EmbeddedKernel()
11 kernel = InProcessKernel()
12 kernel.shell.push({'x': 0, 'y': 1, 'z': 2})
12 kernel.shell.push({'x': 0, 'y': 1, 'z': 2})
13
13
14 # Create a kernel manager for the frontend and register it with the kernel.
14 # Create a kernel manager for the frontend and register it with the kernel.
15 km = QtEmbeddedKernelManager(kernel=kernel)
15 km = QtInProcessKernelManager(kernel=kernel)
16 km.start_channels()
16 km.start_channels()
17 kernel.frontends.append(km)
17 kernel.frontends.append(km)
18
18
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now