Show More
@@ -812,8 +812,9 b' class KernelManager(HasTraits):' | |||
|
812 | 812 | self.kernel = launch_kernel(fname=self.connection_file, **kw) |
|
813 | 813 | |
|
814 | 814 | def shutdown_kernel(self, restart=False): |
|
815 |
""" Attempts to the stop the kernel process cleanly. |
|
|
816 | cannot be stopped, it is killed, if possible. | |
|
815 | """ Attempts to the stop the kernel process cleanly. | |
|
816 | ||
|
817 | If the kernel cannot be stopped and the kernel is local, it is killed. | |
|
817 | 818 | """ |
|
818 | 819 | # FIXME: Shutdown does not work on Windows due to ZMQ errors! |
|
819 | 820 | if sys.platform == 'win32': |
@@ -894,13 +895,17 b' class KernelManager(HasTraits):' | |||
|
894 | 895 | return self.kernel is not None |
|
895 | 896 | |
|
896 | 897 | def kill_kernel(self): |
|
897 |
""" Kill the running kernel. |
|
|
898 | """ Kill the running kernel. | |
|
899 | ||
|
900 | This method blocks until the kernel process has terminated. | |
|
901 | """ | |
|
898 | 902 | if self.has_kernel: |
|
899 | 903 | # Pause the heart beat channel if it exists. |
|
900 | 904 | if self._hb_channel is not None: |
|
901 | 905 | self._hb_channel.pause() |
|
902 | 906 | |
|
903 | # Attempt to kill the kernel. | |
|
907 | # Signal the kernel to terminate (sends SIGKILL on Unix and calls | |
|
908 | # TerminateProcess() on Win32). | |
|
904 | 909 | try: |
|
905 | 910 | self.kernel.kill() |
|
906 | 911 | except OSError as e: |
@@ -915,13 +920,18 b' class KernelManager(HasTraits):' | |||
|
915 | 920 | from errno import ESRCH |
|
916 | 921 | if e.errno != ESRCH: |
|
917 | 922 | raise |
|
923 | ||
|
924 | # Block until the kernel terminates. | |
|
925 | self.kernel.wait() | |
|
918 | 926 | self.kernel = None |
|
919 | 927 | else: |
|
920 | 928 | raise RuntimeError("Cannot kill kernel. No kernel is running!") |
|
921 | 929 | |
|
922 | 930 | def interrupt_kernel(self): |
|
923 |
""" Interrupts the kernel. |
|
|
924 | well supported on all platforms. | |
|
931 | """ Interrupts the kernel. | |
|
932 | ||
|
933 | Unlike ``signal_kernel``, this operation is well supported on all | |
|
934 | platforms. | |
|
925 | 935 | """ |
|
926 | 936 | if self.has_kernel: |
|
927 | 937 | if sys.platform == 'win32': |
@@ -933,8 +943,10 b' class KernelManager(HasTraits):' | |||
|
933 | 943 | raise RuntimeError("Cannot interrupt kernel. No kernel is running!") |
|
934 | 944 | |
|
935 | 945 | def signal_kernel(self, signum): |
|
936 |
""" Sends a signal to the kernel. |
|
|
937 | supported on Windows, this function is only useful on Unix systems. | |
|
946 | """ Sends a signal to the kernel. | |
|
947 | ||
|
948 | Note that since only SIGTERM is supported on Windows, this function is | |
|
949 | only useful on Unix systems. | |
|
938 | 950 | """ |
|
939 | 951 | if self.has_kernel: |
|
940 | 952 | self.kernel.send_signal(signum) |
General Comments 0
You need to be logged in to leave comments.
Login now