Flush output in Python before running execvp (#2258)

This commit is contained in:
Ayaz Salikhov
2025-03-21 13:50:35 +00:00
committed by GitHub
parent 95aa99dd85
commit 929ebdb758
3 changed files with 5 additions and 8 deletions

View File

@@ -8,7 +8,8 @@ import sys
# If we are in a JupyterHub, we pass on to `start-singleuser.py` instead so it does the right thing
if "JUPYTERHUB_API_TOKEN" in os.environ:
print(
"WARNING: using start-singleuser.py instead of start-notebook.py to start a server associated with JupyterHub."
"WARNING: using start-singleuser.py instead of start-notebook.py to start a server associated with JupyterHub.",
flush=True,
)
command = ["/usr/local/bin/start-singleuser.py"] + sys.argv[1:]
os.execvp(command[0], command)
@@ -40,5 +41,5 @@ if "NOTEBOOK_ARGS" in os.environ:
command += sys.argv[1:]
# Execute the command!
print("Executing: " + " ".join(command))
print("Executing: " + " ".join(command), flush=True)
os.execvp(command[0], command)

View File

@@ -20,5 +20,5 @@ if "NOTEBOOK_ARGS" in os.environ:
command += sys.argv[1:]
# Execute the command!
print("Executing: " + " ".join(command))
print("Executing: " + " ".join(command), flush=True)
os.execvp(command[0], command)

View File

@@ -42,11 +42,7 @@ def test_start_notebook(
f"Test that the start-notebook.py launches the {expected_command} server from the env {env} ..."
)
host_port = find_free_port()
container.run_detached(
tty=True,
environment=env,
ports={"8888/tcp": host_port},
)
container.run_detached(environment=env, ports={"8888/tcp": host_port})
# sleeping some time to let the server start
time.sleep(2)
logs = container.get_logs()