mirror of
https://github.com/wassname/jupyter_contrib_nbextensions.git
synced 2026-08-11 11:19:52 +08:00
When configuring, ignore Zombie processes on OS X
This patch was originally implemented by @jonnybaik, but got overwritten somewhere along the line. See Issue #431, Issue #432, and Issue #461
This commit is contained in:
@@ -59,11 +59,25 @@ def update_config(config_file):
|
||||
|
||||
|
||||
for p in psutil.process_iter():
|
||||
if ("python" or "jupyter") in p.name():
|
||||
c = p.cmdline()
|
||||
if len(c) == 2 and "jupyter-notebook" in c[1]:
|
||||
print("Cannot configure while the Jupyter notebook server is running")
|
||||
exit(1)
|
||||
# p.name() can crash due to zombie processes on Mac OS X, so
|
||||
# ignore exceptions due to zombie processes.
|
||||
# (See https://code.google.com/p/psutil/issues/detail?id=428)
|
||||
# Also, searching just the process name for string, "jupyter-notebook" may
|
||||
# not be enough - may have to search the process command to see if
|
||||
# jupyter-notebook is running. Checking the process command can cause an
|
||||
# AccessDenied exception to be thrown for system owned processes, so skip
|
||||
# those as well
|
||||
try:
|
||||
if ("python" or "jupyter") in p.name():
|
||||
c = p.cmdline()
|
||||
if len(c) == 2 and "jupyter-notebook" in c[1]:
|
||||
print("Cannot configure while the Jupyter notebook server is running")
|
||||
exit(1)
|
||||
# Ignore errors caused by zombie processes. Also ignore access
|
||||
# denied exceptions that are thrown when checking the process
|
||||
# comand of processes that do not belong to the user
|
||||
except (psutil.ZombieProcess, psutil.AccessDenied):
|
||||
pass
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "debug":
|
||||
debug = True
|
||||
|
||||
Reference in New Issue
Block a user