Skip to content

Commit b64e985

Browse files
committed
Use SLURM_TMPDIR when possible. Set server-data-dir to temporary dir
1 parent 4487acb commit b64e985

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jupyter_rsession_proxy/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def db_config():
5757
'''
5858
# use mkdtemp() so the directory and its contents don't vanish when
5959
# we're out of scope
60-
db_dir = tempfile.mkdtemp()
60+
db_dir = tempfile.mkdtemp(dir=os.environ.get("SLURM_TMPDIR", "/tmp"))
6161
# create the rserver database config
6262
db_conf = dedent("""
6363
provider=sqlite
@@ -67,10 +67,11 @@ def db_config():
6767
db_config_name = f.name
6868
f.write(db_conf)
6969
f.close()
70-
return db_config_name
70+
return db_dir, db_config_name
7171

7272
def _get_cmd(port):
7373
ntf = tempfile.NamedTemporaryFile()
74+
db_dir, db_cfg = db_config()
7475
cmd = [
7576
get_rstudio_executable('rserver'),
7677
'--auth-none=1',
@@ -80,7 +81,8 @@ def _get_cmd(port):
8081
'--secure-cookie-key-file=' + ntf.name,
8182
'--server-user=' + getpass.getuser(),
8283
'--www-root-path={base_url}rstudio/',
83-
f'--database-config-file={db_config()}'
84+
f'--server-data-dir={db_dir}',
85+
f'--database-config-file={db_cfg}'
8486
]
8587

8688
return cmd

0 commit comments

Comments
 (0)