Skip to content

Commit 9e88dd6

Browse files
authored
Merge pull request #76 from lsst-sqre/tickets/DM-50484
tickets/DM-50484: make debug logging work again
2 parents 1e895f3 + 17653e0 commit 9e88dd6

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- Delete the sections that don't apply -->
2+
3+
### Bug fixes
4+
5+
- Debug mode was not working correctly because it invoked a subshell

src/lsst/rsp/startup/services/labrunner.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import sys
1212
import time
1313
from pathlib import Path
14-
from subprocess import SubprocessError
1514
from typing import Any
1615
from urllib.parse import parse_qsl, urlparse
1716

@@ -751,41 +750,10 @@ def _start(self) -> None:
751750
]
752751
cmd.extend(self._set_timeout_variables())
753752
self._logger.debug("Command to run:", command=cmd)
754-
# Set environment variable to indicate we are inside JupyterLab
755-
# (we want the shell to source loadLSST.bash once we are)
756-
if self._debug:
757-
# Maybe we want to parameterize these?
758-
retries = 10
759-
sleep_interval = 60
760-
for i in range(retries):
761-
self._logger.debug(f"Lab spawn attempt {i+1}/{retries}:")
762-
try:
763-
proc = self._cmd.run(*cmd, env=self._env)
764-
except SubprocessError as exc:
765-
self._logger.exception(
766-
f"Command {cmd} failed to run", exc=exc
767-
)
768-
if proc:
769-
if proc.returncode:
770-
self._logger.error(
771-
f"Lab exited with returncode {proc.returncode}",
772-
proc=proc,
773-
)
774-
else:
775-
self._logger.warning(
776-
"Lab process exited with returncode 0", proc=proc
777-
)
778-
else:
779-
self._logger.error(f"Lab process {cmd} failed to run")
780-
self._logger.info(f"Waiting for {sleep_interval}s")
781-
time.sleep(sleep_interval)
782-
self._logger.debug("Exiting")
783-
sys.exit(0)
784753
# Flush open files before exec()
785754
sys.stdout.flush()
786755
sys.stderr.flush()
787-
# In non-debug mode, we don't use a subprocess: we exec the
788-
# Jupyter process directly. We use os.execvpe() because we
789-
# have a list of arguments we just created and we want to
790-
# pass the environment we built up.
756+
# exec the Jupyter process directly. We use os.execvpe()
757+
# because we have a list of arguments we just created and we
758+
# want to pass the environment we built up.
791759
os.execvpe(cmd[0], cmd, env=self._env)

0 commit comments

Comments
 (0)