Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
hohieuai
force-pushed
the
fix/no-default-timeout
branch
from
October 24, 2026 00:48
af354d4 to
f033214
Compare
hohieuai
force-pushed
the
fix/no-default-timeout
branch
3 times, most recently
from
October 24, 2026 00:56
259555c to
71054ce
Compare
`--timeout` (default 30 s) is meant as an idle threshold, so that
"long-running silent tasks" can raise it and code that keeps printing is
never cut off. Runtime.execute_code passed it to jupyter-kernel-client's
execute_interactive, where it is a deadline for the whole run. Past that
deadline, 0.9.0 polls without waiting and holds a CPU core at ~100%
until the run ends; 1.0.2 raises TimeoutError even while output flows.
For streaming execution without stdin (run, exec, repl), the runtime now
waits for kernel messages itself through the client's public API
(execute, get_iopub_msg, get_shell_msg), in blocking one-second slices.
It raises the same TimeoutError("Timeout waiting for output") once
`timeout` seconds pass with no message from the execution, and
RuntimeError if the connection drops. The default and the flag are
unchanged; executions that use stdin keep the library path.
Fixes googlecolab#183
hohieuai
force-pushed
the
fix/no-default-timeout
branch
from
October 24, 2026 00:56
71054ce to
f23e38a
Compare
Author
|
Superseded by #185, which contains the same fix as a single commit with an updated description. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #183.
Summary
--timeoutnow works the way its design describes. It is an idle threshold: an execution fails only after that many seconds without output, so code that keeps printing is never cut off. While it waits, the local client no longer busy-loops. The flag, its 30-second default, and theTimeoutErrormessage are unchanged.Background
#38 added
--timeoutso users can "increase the idle execution threshold" for tasks that produce no output, and the docs describe it as letting long-running silent tasks run "without being prematurely killed".Runtime.execute_code, however, passed the value tojupyter-kernel-client'sexecute_interactive, which treats it as a deadline for the whole run. The measurements in #183 show the result:TimeoutErrorafter 30 seconds, even while output is flowing.Changes
runtime.py: for streaming execution without stdin (colab run,colab exec,colab repl),execute_codenow waits for kernel messages itself, through the websocket client's public API (execute,get_iopub_msg,get_shell_msg).timeoutseconds, it raises the sameTimeoutError("Timeout waiting for output").Nonewaits without a limit.RuntimeError("Connection was lost.")if the websocket drops, which the old loop only noticed once a message arrived.executepath keep using the library as before.test_colab_runtime_execute_interactive_with_timeoutand the two tests intest_streaming.py. They now driveMockKernelClient(tests/mock_kernel.py), a mock of the websocket client that replays scripted kernel messages on a simulated clock, instead of mockingexecute_interactive, because the streaming path no longer calls it. For example, the timeout test still checks thattimeout=600reaches that branch. A 599-second silence completes, and a 601-second silence raisesTimeoutError.test_streaming.pycover:None;docs/: dated log entries in both design docs.Testing
uv run pytest: 366 passed, 19 skipped. Ruff check and format pass on the changed files.I ran the branch on real CPU runtimes with
jupyter-kernel-client0.8.0 (Google's fork, viatool.uv.sources), 0.9.0 (the PyPI pin), and 1.0.2:--timeoutcolab run, prints every 5 s for 60 s (0.8.0, 0.9.0, 1.0.2)colab run, silent for 45 sTimeoutError: Timeout waiting for output, exit 1, session stoppedcolab run, silent for 45 scolab execon an existing session, prints every 5 s for 60 scolab exec, silent for 45 sTimeoutError: Timeout waiting for output, exit 1colab runNotes
--timeout 30caps the whole run: every longercolab runbusy-loops a CPU core today, and fails once jupyter-kernel-client is upgraded #183 first suggested removing the default timeout. This PR keeps the default and the flag, and makes them behave as feat: Expose --timeout flag for exec and run commands #38 and the docs describe instead.jupyter-kernel-clientpin to>=1.0.2later. That is left out of this PR because it also touchestool.uv.sources.