feat: add reconfirm_record per RFC 6762 §10.4 by bluetoothbot · Pull Request #1772 · python-zeroconf/python-zeroconf
Summary
Add Zeroconf.reconfirm_record / async_reconfirm_record (and the
AsyncZeroconf wrapper) so callers can hint to the cache that a record
may be stale — e.g. when an application-level connect to a discovered
service fails. Implements the cache-flush-on-failure mechanism described
in RFC 6762 §10.4.
Closes #1413
Behaviour
async_reconfirm_record(record)schedules a background task and
returnsTrueif accepted,Falseif the record is not in the cache
or a reconfirmation is already in flight (dedupes by cache entry).- The background task re-queries the record at t=0, 1s, 3s —
the §5.2 doubling-interval pattern and "two or more queries" minimum
from §10.4. - If no fresh copy of the record lands in the cache by t=10s, the
record is force-expired and listeners (e.g.ServiceBrowser) are
notified through the same goodbye path used for TTL-zero responses. reconfirm_recordis the threadsafe variant for callers off the
event loop.
Constants live in const.py (_RECONFIRM_QUERY_INTERVALS_MS,
_RECONFIRM_TIMEOUT_MS) with RFC citations next to them; please do not
tighten without an interop note.
Changes
Zeroconf.async_reconfirm_record/Zeroconf.reconfirm_recordin_core.pyAsyncZeroconf.async_reconfirm_recordinasyncio.py- Background reconfirm pipeline in
RecordManager(_handlers/record_manager.py)
plus.pxdupdates for the newcdef public dict _reconfirm_tasks
and the newcpdefentry point - Timing constants in
const.py - README section explaining when callers should use it
tests/test_reconfirm.py(9 tests) and aquick_reconfirm_timing
fixture inconftest.py
Test plan
-
pytest tests/test_reconfirm.py(9 passed) -
pytest tests/(404 passed, 2 skipped) — no regressions -
ruff check src/ tests/— clean - Cython rebuild of
_handlers/record_manager.pysucceeds (no
closures insidecpdef)
Quality Report
Changes: 8 files changed, 331 insertions(+), 6 deletions(-)
Code scan: clean
Tests: passed (4 PASSED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline