mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
fixes for handling failed chdir in spawners
This commit is contained in:
@@ -11,7 +11,7 @@ import signal
|
|||||||
import sys
|
import sys
|
||||||
import grp
|
import grp
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
from tornado import gen
|
from tornado import gen
|
||||||
from tornado.ioloop import IOLoop, PeriodicCallback
|
from tornado.ioloop import IOLoop, PeriodicCallback
|
||||||
@@ -328,12 +328,13 @@ def _try_setcwd(path):
|
|||||||
try:
|
try:
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
exc = e # break exception instance out of except scope
|
||||||
print("Couldn't set CWD to %s (%s)" % (path, e), file=sys.stderr)
|
print("Couldn't set CWD to %s (%s)" % (path, e), file=sys.stderr)
|
||||||
path, _ = os.path.split(path)
|
path, _ = os.path.split(path)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
print("Couldn't set CWD at all (%s), using temp dir" % e, file=sys.stderr)
|
print("Couldn't set CWD at all (%s), using temp dir" % exc, file=sys.stderr)
|
||||||
td = TemporaryDirectory().name
|
td = mkdtemp()
|
||||||
os.chdir(td)
|
os.chdir(td)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user