Skip to content

Commit

Permalink
Merge pull request #233 from pythonanywhere/master
Browse files Browse the repository at this point in the history
Second attempt at zombie process cleanup
  • Loading branch information
mcg1969 authored Dec 12, 2023
2 parents f461d21 + fa44a90 commit d217629
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions nb_conda_kernels/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import time
import glob
import psutil

import os
from os.path import join, split, dirname, basename, abspath
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ jupyter_client
r-irkernel
requests
flake8
psutil
pytest
pytest-cov
mock
2 changes: 1 addition & 1 deletion testbed/testenv1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dependencies:
- backports.functools_lru_cache
- r-irkernel
- conda-forge::ipykernel
- python=2
- python=3
1 change: 0 additions & 1 deletion tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d217629

Please sign in to comment.