Problem
IListener.listen(maddr, nursery) currently requires every caller to provide a trio.Nursery whose lifetime must outlive the listener. This leaks listener background-task ownership into callers, makes per-listener cleanup ambiguous, and conflicts with
transports (QUIC) that already manage their own background work.
Tracked in Discussion #726 (Issue 1).
Proposal
Drop the nursery parameter from IListener.listen(). Concrete listeners (TCP, WebSocket, QUIC, Circuit Relay v2) own their own background tasks internally via trio.lowlevel.spawn_system_task and are torn down via an explicit close() call.
Acceptance criteria
Implementing PR
#1308
Problem
IListener.listen(maddr, nursery)currently requires every caller to provide atrio.Nurserywhose lifetime must outlive the listener. This leaks listener background-task ownership into callers, makes per-listener cleanup ambiguous, and conflicts withtransports (QUIC) that already manage their own background work.
Tracked in Discussion #726 (Issue 1).
Proposal
Drop the
nurseryparameter fromIListener.listen(). Concrete listeners (TCP, WebSocket, QUIC, Circuit Relay v2) own their own background tasks internally viatrio.lowlevel.spawn_system_taskand are torn down via an explicitclose()call.Acceptance criteria
IListener.listen(maddr)no longer accepts anurseryparameter.TCPListener,WebSocketListener,QUICListener, andCircuitV2Listenerown their background task lifetimes internally.Swarmshutdown callslistener.close()explicitly on every listener.newsfragments/<this-issue>.breaking.rst.tests/utils/factories.pyand example code migrated.TCPListenercorrectly handles repeatedlisten()calls on the same instance (multi-bind contract) without leaking orphaned nurseries.Implementing PR
#1308