From 891458dc61b542b416f5baa26fd6a1efc1e5e46f Mon Sep 17 00:00:00 2001 From: Sam Boyd Date: Mon, 20 Nov 2023 14:17:35 +0000 Subject: [PATCH 1/3] ipykernel has moved on from supporting python2 Co-authored-by: Glenn --- testbed/testenv1.yaml | 2 +- tests/test_runner.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/testbed/testenv1.yaml b/testbed/testenv1.yaml index 62fea6b..da0c2ac 100644 --- a/testbed/testenv1.yaml +++ b/testbed/testenv1.yaml @@ -3,4 +3,4 @@ dependencies: - backports.functools_lru_cache - r-irkernel - conda-forge::ipykernel - - python=2 + - python=3 diff --git a/tests/test_runner.py b/tests/test_runner.py index c2b0036..2b92747 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -11,7 +11,6 @@ from nb_conda_kernels.discovery import CondaKernelProvider from nb_conda_kernels.manager import RUNNER_COMMAND -from jupyter_client.blocking.client import Empty START_TIMEOUT = 10 CMD_TIMEOUT = 3 From ff39e2b329ba72da5263049b2bfca4502a7cc13e Mon Sep 17 00:00:00 2001 From: Sam Boyd Date: Mon, 20 Nov 2023 14:19:46 +0000 Subject: [PATCH 2/3] Wait for child processes to avoid processes becoming zombies when using conda info Co-authored-by: Glenn --- nb_conda_kernels/manager.py | 11 +++++++++++ requirements.txt | 1 + 2 files changed, 12 insertions(+) diff --git a/nb_conda_kernels/manager.py b/nb_conda_kernels/manager.py index 2be34f6..2bdb53e 100644 --- a/nb_conda_kernels/manager.py +++ b/nb_conda_kernels/manager.py @@ -6,6 +6,7 @@ import sys import time import glob +import psutil import os from os.path import join, split, dirname, basename, abspath @@ -138,6 +139,8 @@ def _conda_info(self): self._conda_info_cache = conda_info self._conda_info_cache_expiry = time.time() + CACHE_TIMEOUT + self.wait_for_child_processes_cleanup() + return self._conda_info_cache def _all_envs(self): @@ -390,3 +393,11 @@ def remove_kernel_spec(self, name): else: shutil.rmtree(spec_dir) return spec_dir + + def wait_for_child_processes_cleanup(self): + p = psutil.Process() + for c in p.children(): + try: + c.wait(timeout=0) + except psutil.TimeoutExpired: + pass diff --git a/requirements.txt b/requirements.txt index 54dd2c7..1bfe6b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ jupyter_client r-irkernel requests flake8 +psutil pytest pytest-cov mock From fa44a90409b60ac22734747749de65ad70076c54 Mon Sep 17 00:00:00 2001 From: Glenn Jones Date: Mon, 4 Dec 2023 14:49:59 +0000 Subject: [PATCH 3/3] Updated changelog for 2.3.2. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2c97802..328526a 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,10 @@ To set it in jupyter config file, edit the jupyter configuration file (py or jso ## Changelog +### 2.3.2 + +- Added code to clear zombie child processes left behind by the `conda info` subprocess call in manager.py + ### 2.3.1 - Provide more options to set the display name of an environment (see [`name_format`](README.md#Configuration) setting)