Files
Marc SibsonandClaude Opus 5.5 dbdc140345 Correct library docs and test that skipping api.shutdown() no longer hangs (#549)
* Correct library docs on reactor shutdown and the VM example

docs/library.md warned that the reactor's worker threads are non-daemon,
so an application that skips api.shutdown() never exits. That stopped
being true in 1.4.0: afbc4a5 (#379) dispatches connect setup through
reactor.callFromThread, so the thread pool is started from the daemon
reactor thread and its workers inherit daemon status. The reporter's
script from #255 exits rc=0 on main and hangs only with that one line
reverted. The warning becomes a note: shutdown() is still the clean
teardown, and the reason the context manager doesn't call it (a
reactor cannot be restarted) stays.

The VM example called client.connect(), which does not exist, and
ended without api.shutdown(). The tearDownModule comment in
test_api_lifecycle.py repeated the non-daemon claim; it now states
the constraint that actually makes the call once-per-process.

Smaller option: delete the warning outright. Rejected because readers
on <1.4.0 still hit the hang and the shutdown()/with-block relationship
is not obvious from the API.

Refs #255, #273

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test that a process skipping api.shutdown() still exits

Runs the #255 reproduction in a subprocess -- a with-block around
api.connect() to a closed port, then interpreter exit with no
shutdown() -- and fails if it has not exited within 10s. Verified it
fails with #379's callFromThread reverted to callWhenRunning, which
did connector setup on the application thread and so started the
reactor thread pool there, as non-daemon workers.

Lives in the functional suite: the subprocess starts a reactor, and
the in-process half of this module is the one place allowed to.
Rejected: an in-process check of threading.enumerate() daemon flags,
which would share this module's reactor, whose pool is already
started by setUpModule and so cannot show where it was started from.

Refs #255, #273

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 02:20:26 +00:00
..
…