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
6 changes: 6 additions & 0 deletions src/zeroconf/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import asyncio
import logging
import random
import sys
import threading
from collections.abc import Awaitable
Expand Down Expand Up @@ -544,6 +545,11 @@ async def async_check_service(
instance_name = instance_name_from_service_info(info, strict=strict)
if cooperating_responders:
return

# Wait a random amount of time up avoid collisions and avoid
# a thundering herd when multiple services are started on the network
await self.async_wait(random.randint(150, 250)) # noqa: S311

next_instance_number = 2
next_time = now = current_time_millis()
i = 0
Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Some timing constants

_UNREGISTER_TIME = 125 # ms
_CHECK_TIME = 175 # ms
_CHECK_TIME = 500 # ms
_REGISTER_TIME = 225 # ms
_LISTENER_TIME = 200 # ms
_BROWSER_TIME = 10000 # ms
Expand Down
3 changes: 2 additions & 1 deletion tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()):
# The rest of the startup questions should have
# known answers
for answer_list in answers[1:-2]:
assert len(answer_list) == 1
# Allow 0 or 1 answers due to random delays and timing
assert len(answer_list) <= 1
# Once the TTL is reached, the last question should have no known answers
assert len(answers[-1]) == 0

Expand Down
Loading