8000 vivarium: a timeout inside the guest reaches the host as the wrong error, and a pytest phase ignores its deadline · Issue #1478 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

vivarium: a timeout inside the guest reaches the host as the wrong error, and a pytest phase ignores its deadline #1478

Closed

Description

@Lillecarl

Review findings R6 and R9 on #1444.

  • R6: a guest subprocess.TimeoutExpired arrives as a generic rpyc exception. A guest TimeoutError reads as "guest stopped answering". So:
    • a stuck boot lists no failed units;
    • wait_until_succeeds ends early;
    • children of a timed-out command keep running.
  • R9: a blocking call in a pytest phase ignores the phase timeout and ctl stop.

Fix:

  • The agent returns a typed timeout result and kills the command's process group.
  • The host raises MachineError("... timed out").
  • At the deadline, pytest's worker is told to stop, as pytest-timeout's thread method does. Until then, the docs say the timeout covers awaits only.

Assisted-By: Claude Opus 5.5

Activity

  1. added
    source: vivarium
    on Nov 17, 2026
  2. added theissue type on Nov 17, 2026
  3. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Landed on main (Lock … 58bc20e), each Refs #1478:

    • R6: the agent runs each command in its own process group and kills the group at the timeout. The host raises GuestTimeout (a MachineError), not "guest stopped answering". wait_until_succeeds goes on past a timed-out attempt. A boot that does not end answers starting with its failed units, and the boot recipe fails on it.
    • R9, in part: after each test, the plugin reads the clock. A sync test past the deadline fails the phase, and no later test starts. The timeout option says the limit stops a test only at an await.

    Open, needs a decision: interrupting a test that blocks in pytest's worker thread, at the deadline or on ctl stop.

    1. PyThreadState_SetAsyncExc(worker, PhaseTimeout): stops a Python-level loop; does not break a blocking C call (time.sleep, a socket read), which raises only when it returns. Small, but partial.
    2. pytest-timeout's thread method: dumps the stacks and calls os._exit. The run ends with no verdict, report or teardown. Not usable as is.
    3. Run pytest in a subprocess and kill it: a real interrupt, but a redesign of the plugin (fixtures are guests on the session's loop, reached through a portal).

    Recommendation: 1 now, as a best effort that also covers a stop; 3 only if a blocking C call is seen to hang a phase.


    Assisted-By: Claude Opus 5.5

  4. added
    needs decision
    on Nov 17, 2026
  5. Lillecarl commented on Nov 18, 2026

    @Lillecarl
    ContributorAuthor

    Decided (re-evaluated 2026-11-18): no interrupt of pytest's worker thread. Option 1 is withdrawn.

    PyThreadState_SetAsyncExc raises only between bytecodes. A sync test that runs long almost always waits in C: in time.sleep, a socket read, or portal.call waiting on the loop. In each of those the exception lands only when the wait ends, which is when the clock check already fails the phase. A pure-Python busy loop is the only case it stops, and it brings two hazards: a thread id the OS gives to a new thread, and an exception that lands in pytest's own code and reads as an internal error.

    What holds now: an async test stops at the deadline; a sync test fails the phase when it returns, and no later test starts; the timeout option says so. Option 3 (pytest in a subprocess) stays the route if a blocking test is seen to hang a phase; it gets its own issue then.

    Closing: R6 and the rest of R9 are landed.


    Assisted-By: Claude Opus 5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs decisionsource: vivarium

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0