##// END OF EJS Templates
Improve docstring for InProcessHBChannel
Thomas Kluyver -
Show More
@@ -1,95 +1,100 b''
1 1 """A kernel client for in-process kernels."""
2 2
3 3 # Copyright (c) IPython Development Team.
4 4 # Distributed under the terms of the Modified BSD License.
5 5
6 6 from IPython.kernel.channelsabc import (
7 7 ShellChannelABC, IOPubChannelABC,
8 8 HBChannelABC, StdInChannelABC,
9 9 )
10 10
11 11 from .socket import DummySocket
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Channel classes
15 15 #-----------------------------------------------------------------------------
16 16
17 17 class InProcessChannel(object):
18 18 """Base class for in-process channels."""
19 19 proxy_methods = []
20 20
21 21 def __init__(self, client=None):
22 22 super(InProcessChannel, self).__init__()
23 23 self.client = client
24 24 self._is_alive = False
25 25
26 26 def is_alive(self):
27 27 return self._is_alive
28 28
29 29 def start(self):
30 30 self._is_alive = True
31 31
32 32 def stop(self):
33 33 self._is_alive = False
34 34
35 35 def call_handlers(self, msg):
36 36 """ This method is called in the main thread when a message arrives.
37 37
38 38 Subclasses should override this method to handle incoming messages.
39 39 """
40 40 raise NotImplementedError('call_handlers must be defined in a subclass.')
41 41
42 42 def flush(self, timeout=1.0):
43 43 pass
44 44
45 45
46 46 def call_handlers_later(self, *args, **kwds):
47 47 """ Call the message handlers later.
48 48
49 49 The default implementation just calls the handlers immediately, but this
50 50 method exists so that GUI toolkits can defer calling the handlers until
51 51 after the event loop has run, as expected by GUI frontends.
52 52 """
53 53 self.call_handlers(*args, **kwds)
54 54
55 55 def process_events(self):
56 56 """ Process any pending GUI events.
57 57
58 58 This method will be never be called from a frontend without an event
59 59 loop (e.g., a terminal frontend).
60 60 """
61 61 raise NotImplementedError
62 62
63 63
64 64
65 65 class InProcessHBChannel(object):
66 """See `IPython.kernel.channels.HBChannel` for docstrings."""
66 """A dummy heartbeat channel interface for in-process kernels.
67
68 Normally we use the heartbeat to check that the kernel process is alive.
69 When the kernel is in-process, that doesn't make sense, but clients still
70 expect this interface.
71 """
67 72
68 73 time_to_dead = 3.0
69 74
70 75 def __init__(self, client=None):
71 76 super(InProcessHBChannel, self).__init__()
72 77 self.client = client
73 78 self._is_alive = False
74 79 self._pause = True
75 80
76 81 def is_alive(self):
77 82 return self._is_alive
78 83
79 84 def start(self):
80 85 self._is_alive = True
81 86
82 87 def stop(self):
83 88 self._is_alive = False
84 89
85 90 def pause(self):
86 91 self._pause = True
87 92
88 93 def unpause(self):
89 94 self._pause = False
90 95
91 96 def is_beating(self):
92 97 return not self._pause
93 98
94 99
95 100 HBChannelABC.register(InProcessHBChannel)
General Comments 0
You need to be logged in to leave comments. Login now