|
26 | 26 | from base64 import encodebytes
|
27 | 27 | from pathlib import Path
|
28 | 28 |
|
| 29 | +import jupyter_client |
29 | 30 | from jupyter_client.kernelspec import KernelSpecManager
|
30 | 31 | from jupyter_client.manager import KernelManager
|
31 | 32 | from jupyter_client.session import Session
|
@@ -1644,7 +1645,10 @@ def _update_notebook_dir(self, change):
|
1644 | 1645 | allow_none=True,
|
1645 | 1646 | config=True,
|
1646 | 1647 | help=_i18n(
|
1647 |
| - "The directory to look at for external kernel connection files, if allow_external_kernels is True. Defaults to Jupyter runtime_dir/external_kernels." |
| 1648 | + "The directory to look at for external kernel connection files, if allow_external_kernels is True. " |
| 1649 | + "Defaults to Jupyter runtime_dir/external_kernels. " |
| 1650 | + "Make sure that this directory is not filled with left-over connection files, " |
| 1651 | + "that could result in unnecessary kernel manager creations." |
1648 | 1652 | ),
|
1649 | 1653 | )
|
1650 | 1654 |
|
@@ -1892,20 +1896,28 @@ def init_configurables(self):
|
1892 | 1896 | parent=self,
|
1893 | 1897 | )
|
1894 | 1898 |
|
1895 |
| - if self.allow_external_kernels: |
1896 |
| - external_connection_dir = self.external_connection_dir |
1897 |
| - if external_connection_dir is None: |
1898 |
| - external_connection_dir = str(Path(self.runtime_dir) / "external_kernels") |
1899 |
| - else: |
1900 |
| - external_connection_dir = None |
1901 |
| - |
1902 |
| - self.kernel_manager = self.kernel_manager_class( |
| 1899 | + kwargs = dict( |
1903 | 1900 | parent=self,
|
1904 | 1901 | log=self.log,
|
1905 | 1902 | connection_dir=self.runtime_dir,
|
1906 |
| - external_connection_dir=external_connection_dir, |
1907 | 1903 | kernel_spec_manager=self.kernel_spec_manager,
|
1908 | 1904 | )
|
| 1905 | + if jupyter_client.version_info > (8, 3, 0): |
| 1906 | + if self.allow_external_kernels: |
| 1907 | + external_connection_dir = self.external_connection_dir |
| 1908 | + if external_connection_dir is None: |
| 1909 | + external_connection_dir = str(Path(self.runtime_dir) / "external_kernels") |
| 1910 | + else: |
| 1911 | + external_connection_dir = None |
| 1912 | + |
| 1913 | + kwargs.update(external_connection_dir=external_connection_dir) |
| 1914 | + elif self.allow_external_kernels: |
| 1915 | + self.log.warning( |
| 1916 | + "Although allow_external_kernels=True, external kernels are not supported " |
| 1917 | + "because jupyter-client's version does not allow them (should be >8.3.0)." |
| 1918 | + ) |
| 1919 | + |
| 1920 | + self.kernel_manager = self.kernel_manager_class(**kwargs) |
1909 | 1921 | self.contents_manager = self.contents_manager_class(
|
1910 | 1922 | parent=self,
|
1911 | 1923 | log=self.log,
|
|
0 commit comments