##// END OF EJS Templates
Fixing bug in cleanup of ipc files and adding new to shutdown....
Brian Granger -
Show More
@@ -210,9 +210,9 b' class KernelApp(BaseIPythonApplication):'
210 except (IOError, OSError):
210 except (IOError, OSError):
211 pass
211 pass
212
212
213 self._cleanup_ipc_files()
213 self.cleanup_ipc_files()
214
214
215 def _cleanup_ipc_files(self):
215 def cleanup_ipc_files(self):
216 """cleanup ipc files if we wrote them"""
216 """cleanup ipc files if we wrote them"""
217 if self.transport != 'ipc':
217 if self.transport != 'ipc':
218 return
218 return
@@ -753,9 +753,9 b' class KernelManager(Configurable):'
753 except (IOError, OSError):
753 except (IOError, OSError):
754 pass
754 pass
755
755
756 self._cleanup_ipc_files()
756 self.cleanup_ipc_files()
757
757
758 def _cleanup_ipc_files(self):
758 def cleanup_ipc_files(self):
759 """cleanup ipc files if we wrote them"""
759 """cleanup ipc files if we wrote them"""
760 if self.transport != 'ipc':
760 if self.transport != 'ipc':
761 return
761 return
@@ -829,7 +829,7 b' class KernelManager(Configurable):'
829 from ipkernel import launch_kernel
829 from ipkernel import launch_kernel
830 self.kernel = launch_kernel(fname=self.connection_file, **kw)
830 self.kernel = launch_kernel(fname=self.connection_file, **kw)
831
831
832 def shutdown_kernel(self, restart=False):
832 def shutdown_kernel(self, now=False, restart=False):
833 """ Attempts to the stop the kernel process cleanly.
833 """ Attempts to the stop the kernel process cleanly.
834
834
835 If the kernel cannot be stopped and the kernel is local, it is killed.
835 If the kernel cannot be stopped and the kernel is local, it is killed.
@@ -843,22 +843,28 b' class KernelManager(Configurable):'
843 if self._hb_channel is not None:
843 if self._hb_channel is not None:
844 self._hb_channel.pause()
844 self._hb_channel.pause()
845
845
846 # Don't send any additional kernel kill messages immediately, to give
846 if now:
847 # the kernel a chance to properly execute shutdown actions. Wait for at
848 # most 1s, checking every 0.1s.
849 self.shell_channel.shutdown(restart=restart)
850 for i in range(10):
851 if self.is_alive:
852 time.sleep(0.1)
853 else:
854 break
855 else:
856 # OK, we've waited long enough.
857 if self.has_kernel:
847 if self.has_kernel:
858 self.kill_kernel()
848 self.kill_kernel()
849 else:
850 # Don't send any additional kernel kill messages immediately, to give
851 # the kernel a chance to properly execute shutdown actions. Wait for at
852 # most 1s, checking every 0.1s.
853 self.shell_channel.shutdown(restart=restart)
854 for i in range(10):
855 if self.is_alive:
856 time.sleep(0.1)
857 else:
858 break
859 else:
860 # OK, we've waited long enough.
861 if self.has_kernel:
862 self.kill_kernel()
859
863
860 if not restart:
864 if not restart:
861 self.cleanup_connection_file()
865 self.cleanup_connection_file()
866 else:
867 self.cleanup_ipc_files()
862
868
863 def restart_kernel(self, now=False, **kw):
869 def restart_kernel(self, now=False, **kw):
864 """Restarts a kernel with the arguments that were used to launch it.
870 """Restarts a kernel with the arguments that were used to launch it.
@@ -885,11 +891,7 b' class KernelManager(Configurable):'
885 "No previous call to 'start_kernel'.")
891 "No previous call to 'start_kernel'.")
886 else:
892 else:
887 # Stop currently running kernel.
893 # Stop currently running kernel.
888 if self.has_kernel:
894 self.shutdown_kernel(now=now, restart=True)
889 if now:
890 self.kill_kernel()
891 else:
892 self.shutdown_kernel(restart=True)
893
895
894 # Start new kernel.
896 # Start new kernel.
895 self._launch_args.update(kw)
897 self._launch_args.update(kw)
General Comments 0
You need to be logged in to leave comments. Login now