##// END OF EJS Templates
Merge pull request #1 from minrk/kill-bg-processes...
Takafumi Arakaki -
r7628:375a648c merge
parent child Browse files
Show More
@@ -344,7 +344,7 b' class KernelHandler(AuthenticatedHandler):'
344 @web.authenticated
344 @web.authenticated
345 def delete(self, kernel_id):
345 def delete(self, kernel_id):
346 km = self.application.kernel_manager
346 km = self.application.kernel_manager
347 km.kill_kernel(kernel_id)
347 km.shutdown_kernel(kernel_id)
348 self.set_status(204)
348 self.set_status(204)
349 self.finish()
349 self.finish()
350
350
@@ -43,7 +43,7 b' class MultiKernelManager(LoggingConfigurable):'
43 """A class for managing multiple kernels."""
43 """A class for managing multiple kernels."""
44
44
45 kernel_manager_class = DottedObjectName(
45 kernel_manager_class = DottedObjectName(
46 "IPython.zmq.kernelmanager.KernelManager", config=True,
46 "IPython.zmq.blockingkernelmanager.BlockingKernelManager", config=True,
47 help="""The kernel manager class. This is configurable to allow
47 help="""The kernel manager class. This is configurable to allow
48 subclassing of the KernelManager for customized behavior.
48 subclassing of the KernelManager for customized behavior.
49 """
49 """
@@ -87,9 +87,22 b' class MultiKernelManager(LoggingConfigurable):'
87 config=self.config,
87 config=self.config,
88 )
88 )
89 km.start_kernel(**kwargs)
89 km.start_kernel(**kwargs)
90 # start just the shell channel, needed for graceful restart
91 km.start_channels(shell=True, sub=False, stdin=False, hb=False)
90 self._kernels[kernel_id] = km
92 self._kernels[kernel_id] = km
91 return kernel_id
93 return kernel_id
92
94
95 def shutdown_kernel(self, kernel_id):
96 """Shutdown a kernel by its kernel uuid.
97
98 Parameters
99 ==========
100 kernel_id : uuid
101 The id of the kernel to shutdown.
102 """
103 self.get_kernel(kernel_id).shutdown_kernel()
104 del self._kernels[kernel_id]
105
93 def kill_kernel(self, kernel_id):
106 def kill_kernel(self, kernel_id):
94 """Kill a kernel by its kernel uuid.
107 """Kill a kernel by its kernel uuid.
95
108
@@ -267,6 +280,13 b' class MappingKernelManager(MultiKernelManager):'
267 self.log.info("Using existing kernel: %s" % kernel_id)
280 self.log.info("Using existing kernel: %s" % kernel_id)
268 return kernel_id
281 return kernel_id
269
282
283 def shutdown_kernel(self, kernel_id):
284 """Shutdown a kernel and remove its notebook association."""
285 self._check_kernel_id(kernel_id)
286 super(MappingKernelManager, self).shutdown_kernel(kernel_id)
287 self.delete_mapping_for_kernel(kernel_id)
288 self.log.info("Kernel shutdown: %s" % kernel_id)
289
270 def kill_kernel(self, kernel_id):
290 def kill_kernel(self, kernel_id):
271 """Kill a kernel and remove its notebook association."""
291 """Kill a kernel and remove its notebook association."""
272 self._check_kernel_id(kernel_id)
292 self._check_kernel_id(kernel_id)
@@ -284,7 +304,7 b' class MappingKernelManager(MultiKernelManager):'
284 """Restart a kernel while keeping clients connected."""
304 """Restart a kernel while keeping clients connected."""
285 self._check_kernel_id(kernel_id)
305 self._check_kernel_id(kernel_id)
286 km = self.get_kernel(kernel_id)
306 km = self.get_kernel(kernel_id)
287 km.restart_kernel(now=True)
307 km.restart_kernel()
288 self.log.info("Kernel restarted: %s" % kernel_id)
308 self.log.info("Kernel restarted: %s" % kernel_id)
289 return kernel_id
309 return kernel_id
290
310
@@ -532,9 +532,9 b' class NotebookApp(BaseIPythonApplication):'
532 """
532 """
533 self.log.info('Shutting down kernels')
533 self.log.info('Shutting down kernels')
534 km = self.kernel_manager
534 km = self.kernel_manager
535 # copy list, since kill_kernel deletes keys
535 # copy list, since shutdown_kernel deletes keys
536 for kid in list(km.kernel_ids):
536 for kid in list(km.kernel_ids):
537 km.kill_kernel(kid)
537 km.shutdown_kernel(kid)
538
538
539 def start(self):
539 def start(self):
540 ip = self.ip if self.ip else '[all ip addresses on your system]'
540 ip = self.ip if self.ip else '[all ip addresses on your system]'
General Comments 0
You need to be logged in to leave comments. Login now