You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): release sockets when close runs before engine setup completes
When ``Zeroconf`` is constructed inside a running asyncio loop, the
engine's socket→transport wrapping happens in a scheduled task. If the
caller closed the instance before that task ran (e.g. an error path
that bails out immediately, or a sync ``zc.close()`` called from the
same loop before any await), ``_async_shutdown`` had no transports to
close and the raw sockets passed to the engine in ``__init__`` leaked
their FDs until interpreter shutdown.
``_async_create_endpoints`` now releases its handle on each socket as
the transport adopts it, and ``_async_shutdown`` cancels any pending
setup task and closes whatever sockets were never adopted. The async
close path tolerates a cancelled setup task instead of asserting on
``_cleanup_timer`` that was never scheduled.
Also clean up the test-side leaks surfaced by issue #1133: add the
missing ``async_close`` / ``close`` calls in tests that constructed a
``Zeroconf`` or ``AsyncZeroconf`` and never tore it down, give
``test_shutdown_loop`` an explicit ``loop.close()``, and add a no-op
``update_service`` to the ``ServiceListener`` subclass in
``test_service_browser_listeners_no_update_service`` so the browser
thread doesn't surface a ``NotImplementedError``.
Closes#1133.
0 commit comments