Skip to content
Merged
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
5 changes: 3 additions & 2 deletions tests/services/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ def current_time_millis():
return time.time() * 1000 + time_offset * 1000

expected_ttl = const._DNS_HOST_TTL

nbr_answers = 0

def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT):
Expand All @@ -454,6 +453,8 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT):
unexpected_ttl.set()

got_query.set()
got_query.clear()

old_send(out, addr=addr, port=port)

# patch the zeroconf send
Expand Down Expand Up @@ -482,13 +483,13 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT):
# is greater than half the original TTL
sleep_count = 0
test_iterations = 50

while nbr_answers < test_iterations:
# Increase simulated time shift by 1/4 of the TTL in seconds
time_offset += expected_ttl / 4
zeroconf_browser.notify_all()
sleep_count += 1
got_query.wait(0.1)
got_query.clear()
# Prevent the test running indefinitely in an error condition
assert sleep_count < test_iterations * 4
assert not unexpected_ttl.is_set()
Expand Down