##// END OF EJS Templates
set default client_class for QtKernelManager...
MinRK -
Show More
@@ -1,52 +1,53 b''
1 1 """ Defines a KernelClient that provides signals and slots.
2 2 """
3 3
4 4 from IPython.external.qt import QtCore
5 5
6 6 # Local imports
7 from IPython.utils.traitlets import Bool
7 from IPython.utils.traitlets import Bool, DottedObjectName
8 8
9 9 from IPython.kernel import KernelManager
10 10 from IPython.kernel.restarter import KernelRestarter
11 11
12 12 from .kernel_mixins import QtKernelManagerMixin, QtKernelRestarterMixin
13 13
14 14
15 15 class QtKernelRestarter(KernelRestarter, QtKernelRestarterMixin):
16 16
17 17 def start(self):
18 18 if self._timer is None:
19 19 self._timer = QtCore.QTimer()
20 20 self._timer.timeout.connect(self.poll)
21 21 self._timer.start(self.time_to_dead * 1000)
22 22
23 23 def stop(self):
24 24 self._timer.stop()
25 25
26 26 def poll(self):
27 27 super(QtKernelRestarter, self).poll()
28 28
29 29
30 30 class QtKernelManager(KernelManager, QtKernelManagerMixin):
31 31 """A KernelManager with Qt signals for restart"""
32 32
33 client_class = DottedObjectName('IPython.qt.client.QtKernelClient')
33 34 autorestart = Bool(True, config=True)
34 35
35 36 def start_restarter(self):
36 37 if self.autorestart and self.has_kernel:
37 38 if self._restarter is None:
38 39 self._restarter = QtKernelRestarter(
39 40 kernel_manager=self,
40 41 parent=self,
41 42 log=self.log,
42 43 )
43 44 self._restarter.add_callback(self._handle_kernel_restarted)
44 45 self._restarter.start()
45 46
46 47 def stop_restarter(self):
47 48 if self.autorestart:
48 49 if self._restarter is not None:
49 50 self._restarter.stop()
50 51
51 52 def _handle_kernel_restarted(self):
52 53 self.kernel_restarted.emit()
General Comments 0
You need to be logged in to leave comments. Login now