Show More
@@ -11,11 +11,6 b' try:' | |||
|
11 | 11 | except ImportError: |
|
12 | 12 | from Queue import Queue, Empty # Py 2 |
|
13 | 13 | |
|
14 | from IPython.kernel.channelsabc import ShellChannelABC, IOPubChannelABC, \ | |
|
15 | StdInChannelABC | |
|
16 | from IPython.kernel.channels import HBChannel,\ | |
|
17 | make_iopub_socket, make_shell_socket, make_stdin_socket,\ | |
|
18 | InvalidPortNumber, major_protocol_version | |
|
19 | 14 | from IPython.utils.py3compat import string_types, iteritems |
|
20 | 15 | |
|
21 | 16 | # some utilities to validate message structure, these might get moved elsewhere |
@@ -121,15 +116,3 b' class ZMQSocketChannel(object):' | |||
|
121 | 116 | def start(self): |
|
122 | 117 | pass |
|
123 | 118 | |
|
124 | ||
|
125 | ||
|
126 | class BlockingHBChannel(HBChannel): | |
|
127 | ||
|
128 | # This kernel needs quicker monitoring, shorten to 1 sec. | |
|
129 | # less than 0.5s is unreliable, and will get occasional | |
|
130 | # false reports of missed beats. | |
|
131 | time_to_dead = 1. | |
|
132 | ||
|
133 | def call_handlers(self, since_last_heartbeat): | |
|
134 | """ Pause beating on missed heartbeat. """ | |
|
135 | pass |
@@ -11,8 +11,9 b' except ImportError:' | |||
|
11 | 11 | from Queue import Empty # Python 2 |
|
12 | 12 | |
|
13 | 13 | from IPython.utils.traitlets import Type |
|
14 | from IPython.kernel.channels import HBChannel | |
|
14 | 15 | from IPython.kernel.client import KernelClient |
|
15 |
from .channels import ZMQSocketChannel |
|
|
16 | from .channels import ZMQSocketChannel | |
|
16 | 17 | |
|
17 | 18 | class BlockingKernelClient(KernelClient): |
|
18 | 19 | def wait_for_ready(self): |
@@ -35,4 +36,4 b' class BlockingKernelClient(KernelClient):' | |||
|
35 | 36 | shell_channel_class = Type(ZMQSocketChannel) |
|
36 | 37 | iopub_channel_class = Type(ZMQSocketChannel) |
|
37 | 38 | stdin_channel_class = Type(ZMQSocketChannel) |
|
38 |
hb_channel_class = Type( |
|
|
39 | hb_channel_class = Type(HBChannel) |
@@ -210,7 +210,7 b' class HBChannel(ZMQSocketChannel):' | |||
|
210 | 210 | as appropriate. |
|
211 | 211 | """ |
|
212 | 212 | |
|
213 |
time_to_dead = |
|
|
213 | time_to_dead = 1. | |
|
214 | 214 | socket = None |
|
215 | 215 | poller = None |
|
216 | 216 | _running = None |
@@ -332,7 +332,7 b' class HBChannel(ZMQSocketChannel):' | |||
|
332 | 332 | so that some logic must be done to ensure that the application level |
|
333 | 333 | handlers are called in the application thread. |
|
334 | 334 | """ |
|
335 | raise NotImplementedError('call_handlers must be defined in a subclass.') | |
|
335 | pass | |
|
336 | 336 | |
|
337 | 337 | |
|
338 | 338 | HBChannelABC.register(HBChannel) |
@@ -62,15 +62,26 b' class InProcessChannel(object):' | |||
|
62 | 62 | |
|
63 | 63 | |
|
64 | 64 | |
|
65 |
class InProcessHBChannel( |
|
|
65 | class InProcessHBChannel(object): | |
|
66 | 66 | """See `IPython.kernel.channels.HBChannel` for docstrings.""" |
|
67 | 67 | |
|
68 | 68 | time_to_dead = 3.0 |
|
69 | 69 | |
|
70 |
def __init__(self, |
|
|
71 |
super(InProcessHBChannel, self).__init__( |
|
|
70 | def __init__(self, client=None): | |
|
71 | super(InProcessHBChannel, self).__init__() | |
|
72 | self.client = client | |
|
73 | self._is_alive = False | |
|
72 | 74 | self._pause = True |
|
73 | 75 | |
|
76 | def is_alive(self): | |
|
77 | return self._is_alive | |
|
78 | ||
|
79 | def start(self): | |
|
80 | self._is_alive = True | |
|
81 | ||
|
82 | def stop(self): | |
|
83 | self._is_alive = False | |
|
84 | ||
|
74 | 85 | def pause(self): |
|
75 | 86 | self._pause = True |
|
76 | 87 |
@@ -19,11 +19,21 b' from IPython.kernel.channels import HBChannel,\\' | |||
|
19 | 19 | make_shell_socket, make_iopub_socket, make_stdin_socket |
|
20 | 20 | from IPython.kernel import KernelClient |
|
21 | 21 | |
|
22 |
from .kernel_mixins import |
|
|
22 | from .kernel_mixins import QtKernelClientMixin | |
|
23 | 23 | from .util import SuperQObject |
|
24 | 24 | |
|
25 |
class QtHBChannel( |
|
|
26 | pass | |
|
25 | class QtHBChannel(SuperQObject, HBChannel): | |
|
26 | # A longer timeout than the base class | |
|
27 | time_to_dead = 3.0 | |
|
28 | ||
|
29 | # Emitted when the kernel has died. | |
|
30 | kernel_died = QtCore.Signal(object) | |
|
31 | ||
|
32 | def call_handlers(self, since_last_heartbeat): | |
|
33 | """ Reimplemented to emit signals instead of making callbacks. | |
|
34 | """ | |
|
35 | # Emit the generic signal. | |
|
36 | self.kernel_died.emit(since_last_heartbeat) | |
|
27 | 37 | |
|
28 | 38 | from IPython.core.release import kernel_protocol_version_info |
|
29 | 39 |
@@ -10,16 +10,13 b' from IPython.kernel.inprocess.channels import InProcessChannel' | |||
|
10 | 10 | |
|
11 | 11 | from IPython.utils.traitlets import Type |
|
12 | 12 | from .kernel_mixins import ( ChannelQObject, |
|
13 |
|
|
|
13 | QtKernelClientMixin, | |
|
14 | 14 | QtKernelManagerMixin, |
|
15 | 15 | ) |
|
16 | 16 | |
|
17 | 17 | class QtInProcessChannel(ChannelQObject, InProcessChannel): |
|
18 | 18 | pass |
|
19 | 19 | |
|
20 | class QtInProcessHBChannel(QtHBChannelMixin, InProcessHBChannel): | |
|
21 | pass | |
|
22 | ||
|
23 | 20 | class QtInProcessKernelClient(QtKernelClientMixin, InProcessKernelClient): |
|
24 | 21 | """ An in-process KernelManager with signals and slots. |
|
25 | 22 | """ |
@@ -27,7 +24,7 b' class QtInProcessKernelClient(QtKernelClientMixin, InProcessKernelClient):' | |||
|
27 | 24 | iopub_channel_class = Type(QtInProcessChannel) |
|
28 | 25 | shell_channel_class = Type(QtInProcessChannel) |
|
29 | 26 | stdin_channel_class = Type(QtInProcessChannel) |
|
30 |
hb_channel_class = Type( |
|
|
27 | hb_channel_class = Type(InProcessHBChannel) | |
|
31 | 28 | |
|
32 | 29 | class QtInProcessKernelManager(QtKernelManagerMixin, InProcessKernelManager): |
|
33 | 30 | client_class = __module__ + '.QtInProcessKernelClient' |
@@ -53,17 +53,6 b' class ChannelQObject(SuperQObject):' | |||
|
53 | 53 | self.process_events() |
|
54 | 54 | |
|
55 | 55 | |
|
56 | class QtHBChannelMixin(ChannelQObject): | |
|
57 | ||
|
58 | # Emitted when the kernel has died. | |
|
59 | kernel_died = QtCore.Signal(object) | |
|
60 | ||
|
61 | def call_handlers(self, since_last_heartbeat): | |
|
62 | """ Reimplemented to emit signals instead of making callbacks. | |
|
63 | """ | |
|
64 | self.kernel_died.emit(since_last_heartbeat) | |
|
65 | ||
|
66 | ||
|
67 | 56 | class QtKernelRestarterMixin(MetaQObjectHasTraits('NewBase', (HasTraits, SuperQObject), {})): |
|
68 | 57 | |
|
69 | 58 | _timer = None |
General Comments 0
You need to be logged in to leave comments.
Login now