Skip to content

Commit a5166fd

Browse files
committed
[install] remove psutil requirement by using notebook's own check
use the notebook-provided list_running_servers function to check for running notebook servers, rather than using our previous psutil effort.
1 parent 2a71b68 commit a5166fd

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

conda.recipe/meta.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ requirements:
2929
- jupyter_nbextensions_configurator >=0.2.4
3030
- nbconvert >=4.2
3131
- notebook >=4.0
32-
- psutil >=2.2.1
3332
- pyyaml
3433
- setuptools
3534
- tornado

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def main():
6969
'jupyter_nbextensions_configurator >=0.2.4',
7070
'nbconvert >=4.2',
7171
'notebook >=4.0',
72-
'psutil >=2.2.1',
7372
'pyyaml',
7473
'tornado',
7574
'traitlets >=4.1',

src/jupyter_contrib_nbextensions/install.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
import jupyter_highlight_selected_word
1212
import latex_envs
13-
import psutil
1413
from jupyter_contrib_core.notebook_compat import nbextensions
1514
from jupyter_nbextensions_configurator.application import \
1615
EnableJupyterNbextensionsConfiguratorApp
16+
from notebook.notebookapp import list_running_servers
1717
from traitlets.config import Config
1818
from traitlets.config.manager import BaseJSONConfigManager
1919

@@ -24,28 +24,11 @@ class NotebookRunningError(Exception):
2424
pass
2525

2626

27-
def notebook_is_running():
27+
def notebook_is_running(runtime_dir=None):
2828
"""Return true if a notebook process appears to be running."""
29-
for p in psutil.process_iter():
30-
# p.name() can throw exceptions due to zombie processes on Mac OS X, so
31-
# ignore psutil.ZombieProcess
32-
# (See https://code.google.com/p/psutil/issues/detail?id=428)
33-
34-
# It isn't enough to search just the process name, we have to
35-
# search the process command to see if jupyter-notebook is running.
36-
37-
# Checking the process command can cause an AccessDenied exception to
38-
# be thrown for system owned processes, ignore those as well
39-
try:
40-
# use lower, since python may be Python, e.g. on OSX
41-
if ('python' or 'jupyter') in p.name().lower():
42-
for arg in p.cmdline():
43-
# the missing k is deliberate!
44-
# The usual string 'jupyter-notebook' can get truncated.
45-
if 'jupyter-noteboo' in arg:
46-
return True
47-
except (psutil.ZombieProcess, psutil.AccessDenied):
48-
pass
29+
try:
30+
return bool(next(list_running_servers(runtime_dir=runtime_dir)))
31+
except StopIteration:
4932
return False
5033

5134

0 commit comments

Comments
 (0)