##// END OF EJS Templates
Restore QtInProcessHBChannel class
Thomas Kluyver -
Show More
@@ -1,70 +1,75 b''
1 1 """ Defines an in-process KernelManager with signals and slots.
2 2 """
3 3
4 4 # Local imports.
5 5 from IPython.external.qt import QtCore
6 6 from IPython.kernel.inprocess import (
7 7 InProcessHBChannel, InProcessKernelClient, InProcessKernelManager,
8 8 )
9 9 from IPython.kernel.inprocess.channels import InProcessChannel
10 10
11 11 from IPython.utils.traitlets import Type
12 12 from .util import SuperQObject
13 13 from .kernel_mixins import (
14 14 QtKernelClientMixin, QtKernelManagerMixin,
15 15 )
16 16
17 17 class QtInProcessChannel(SuperQObject, InProcessChannel):
18 18 # Emitted when the channel is started.
19 19 started = QtCore.Signal()
20 20
21 21 # Emitted when the channel is stopped.
22 22 stopped = QtCore.Signal()
23 23
24 24 # Emitted when any message is received.
25 25 message_received = QtCore.Signal(object)
26 26
27 27 def start(self):
28 28 """ Reimplemented to emit signal.
29 29 """
30 30 super(QtInProcessChannel, self).start()
31 31 self.started.emit()
32 32
33 33 def stop(self):
34 34 """ Reimplemented to emit signal.
35 35 """
36 36 super(QtInProcessChannel, self).stop()
37 37 self.stopped.emit()
38 38
39 39 def call_handlers_later(self, *args, **kwds):
40 40 """ Call the message handlers later.
41 41 """
42 42 do_later = lambda: self.call_handlers(*args, **kwds)
43 43 QtCore.QTimer.singleShot(0, do_later)
44 44
45 45 def call_handlers(self, msg):
46 46 self.message_received.emit(msg)
47 47
48 48 def process_events(self):
49 49 """ Process any pending GUI events.
50 50 """
51 51 QtCore.QCoreApplication.instance().processEvents()
52 52
53 53 def flush(self, timeout=1.0):
54 54 """ Reimplemented to ensure that signals are dispatched immediately.
55 55 """
56 56 super(QtInProcessChannel, self).flush()
57 57 self.process_events()
58 58
59 59
60 class QtInProcessHBChannel(SuperQObject, InProcessHBChannel):
61 # This signal will never be fired, but it needs to exist
62 kernel_died = QtCore.Signal()
63
64
60 65 class QtInProcessKernelClient(QtKernelClientMixin, InProcessKernelClient):
61 66 """ An in-process KernelManager with signals and slots.
62 67 """
63 68
64 69 iopub_channel_class = Type(QtInProcessChannel)
65 70 shell_channel_class = Type(QtInProcessChannel)
66 71 stdin_channel_class = Type(QtInProcessChannel)
67 hb_channel_class = Type(InProcessHBChannel)
72 hb_channel_class = Type(QtInProcessHBChannel)
68 73
69 74 class QtInProcessKernelManager(QtKernelManagerMixin, InProcessKernelManager):
70 75 client_class = __module__ + '.QtInProcessKernelClient'
General Comments 0
You need to be logged in to leave comments. Login now