Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/zeroconf/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ def setup(self, loop: asyncio.AbstractEventLoop, loop_thread_ready: Optional[thr
async def _async_setup(self, loop_thread_ready: Optional[threading.Event]) -> None:
"""Set up the instance."""
assert self.loop is not None
self._cleanup_timer = self.loop.call_later(
millis_to_seconds(_CACHE_CLEANUP_INTERVAL), self._async_cache_cleanup
)
self._cleanup_timer = self.loop.call_later(_CACHE_CLEANUP_INTERVAL, self._async_cache_cleanup)
await self._async_create_endpoints()
assert self.running_event is not None
self.running_event.set()
Expand Down Expand Up @@ -213,9 +211,7 @@ def _async_cache_cleanup(self) -> None:
)
self.zc.record_manager.async_updates_complete(False)
assert self.loop is not None
self._cleanup_timer = self.loop.call_later(
millis_to_seconds(_CACHE_CLEANUP_INTERVAL), self._async_cache_cleanup
)
self._cleanup_timer = self.loop.call_later(_CACHE_CLEANUP_INTERVAL, self._async_cache_cleanup)

async def _async_close(self) -> None:
"""Cancel and wait for the cleanup task to finish."""
Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
_BROWSER_TIME = 1000 # ms
_DUPLICATE_QUESTION_INTERVAL = _BROWSER_TIME - 1 # ms
_BROWSER_BACKOFF_LIMIT = 3600 # s
_CACHE_CLEANUP_INTERVAL = 10000 # ms
_CACHE_CLEANUP_INTERVAL = 10 # s
_LOADED_SYSTEM_TIMEOUT = 10 # s
_STARTUP_TIMEOUT = 9 # s must be lower than _LOADED_SYSTEM_TIMEOUT
_ONE_SECOND = 1000 # ms
Expand Down
2 changes: 1 addition & 1 deletion tests/services/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def mock_incoming_msg(records: Iterable[r.DNSRecord]) -> r.DNSIncoming:


@patch.object(_handlers, '_DNS_PTR_MIN_TTL', 1)
@patch.object(_core, "_CACHE_CLEANUP_INTERVAL", 10)
@patch.object(_core, "_CACHE_CLEANUP_INTERVAL", 0.01)
def test_service_browser_expire_callbacks():
"""Test that the ServiceBrowser matching does not match partial names."""
# instantiate a zeroconf instance
Expand Down
6 changes: 2 additions & 4 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ async def make_query():
# which is not threadsafe
@pytest.mark.asyncio
async def test_reaper():
with patch.object(_core, "_CACHE_CLEANUP_INTERVAL", 10):
assert _core._CACHE_CLEANUP_INTERVAL == 10
with patch.object(_core, "_CACHE_CLEANUP_INTERVAL", 0.01):
aiozc = AsyncZeroconf(interfaces=['127.0.0.1'])
zeroconf = aiozc.zeroconf
cache = zeroconf.cache
Expand Down Expand Up @@ -88,8 +87,7 @@ async def test_reaper():
@pytest.mark.asyncio
async def test_reaper_aborts_when_done():
"""Ensure cache cleanup stops when zeroconf is done."""
with patch.object(_core, "_CACHE_CLEANUP_INTERVAL", 10):
assert _core._CACHE_CLEANUP_INTERVAL == 10
with patch.object(_core, "_CACHE_CLEANUP_INTERVAL", 0.01):
aiozc = AsyncZeroconf(interfaces=['127.0.0.1'])
zeroconf = aiozc.zeroconf
record_with_10s_ttl = r.DNSAddress('a', const._TYPE_SOA, const._CLASS_IN, 10, b'a')
Expand Down