From d80247a686bc64b0ed9a1830ae21ad0913e91b9d Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Wed, 13 May 2015 16:02:22 -0700 Subject: [PATCH] Fix list_running_servers when runtime dir not created I ran into this now that we actually use $XDG_RUNTIME_DIR, because it's cleared on restart. --- jupyter_notebook/notebookapp.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jupyter_notebook/notebookapp.py b/jupyter_notebook/notebookapp.py index b037f9abd..0693d2d6b 100644 --- a/jupyter_notebook/notebookapp.py +++ b/jupyter_notebook/notebookapp.py @@ -1126,6 +1126,11 @@ def list_running_servers(runtime_dir=None): """ if runtime_dir is None: runtime_dir = jupyter_runtime_dir() + + # The runtime dir might not exist + if not os.path.isdir(runtime_dir): + return + for file in os.listdir(runtime_dir): if file.startswith('nbserver-'): with io.open(os.path.join(runtime_dir, file), encoding='utf-8') as f: