Skip to content

Commit 309295c

Browse files
test: remove scheduling sensitivity from the prestart timeout test
The second hook now blocks indefinitely, so the phase deadline lands in it regardless of scheduler load. Also notes in the docs that threads started directly do not inherit the capture context.
1 parent b437714 commit 309295c

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎docs/serverless/worker.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ to the failure it reports, as `logs`. Opt in using `RUNPOD_LOG_CAPTURE`:
7474

7575
Capture replaces `sys.stdout`/`sys.stderr` at worker startup, so it sees `print`
7676
and direct stream writes made while a hook or handler runs. It does not see
77-
child processes and log handlers created before startup.
77+
child processes, log handlers created before startup, or threads your code
78+
starts directly (`asyncio.to_thread` is captured).
7879

7980
## Worker Refresh
8081

‎tests/test_serverless/test_prestart.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,20 @@ def warm_cache():
8181
assert payload["error_message"] == "CUDA OOM"
8282

8383
def test_timeout_bounds_the_whole_phase_and_names_current_hook(self):
84+
started = []
85+
8486
async def first():
85-
await asyncio.sleep(0.03)
87+
started.append("first")
8688

8789
async def second():
88-
await asyncio.sleep(0.03)
90+
started.append("second")
91+
# Blocks forever, so the deadline lands here on any scheduler.
92+
await asyncio.Event().wait()
8993

9094
with self.assertRaises(PrestartTimeout) as ctx:
91-
_run(run_prestart_hooks_async((first, second), timeout=0.04))
95+
_run(run_prestart_hooks_async((first, second), timeout=0.05))
9296

97+
assert started == ["first", "second"]
9398
assert ctx.exception.hook == "second"
9499

95100
def test_hook_raised_cancelled_error_is_a_prestart_failure(self):

0 commit comments

Comments
 (0)