FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor: compute probe pacing from fresh clock reads by bdraco · Pull Request #1888 · python-zeroconf/python-zeroconf · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
28 changes: 15 additions & 13 deletions src/zeroconf/_core.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -263,29 +263,31 @@ async def async_check_service(
await self.async_wait(random.randint(*_PROBE_RANDOM_DELAY_INTERVAL)) # noqa: S311

next_instance_number = 2
next_time = now = current_time_millis()
i = 0
while i < _REGISTER_BROADCASTS:
# check for a name conflict
while self.cache.current_entry_with_name_and_alias(info.type, info.name):
probes_sent = 0
next_probe_at = current_time_millis()
while probes_sent < _REGISTER_BROADCASTS:
# check for a name conflict; a cache update during the wait below
# wakes async_wait, so a conflicting response lands here promptly
if self.cache.current_entry_with_name_and_alias(info.type, info.name):
if not allow_name_change:
raise NonUniqueNameException

# change the name and look for a conflict
# change the name and restart probing from zero
info.name = f"{instance_name}-{next_instance_number}.{info.type}"
next_instance_number += 1
service_type_name(info.name, strict=strict)
next_time = now
i = 0
probes_sent = 0
next_probe_at = current_time_millis()
continue

if now < next_time:
await self.async_wait(next_time - now)
now = current_time_millis()
remaining = next_probe_at - current_time_millis()
if remaining > 0:
await self.async_wait(remaining)
continue

self.async_send(self.generate_service_query(info))
i += 1
next_time += _CHECK_TIME
probes_sent += 1
next_probe_at += _CHECK_TIME

async def async_get_service_info(
self,
Expand Down
Loading

Back | FazBrowse Home | New Git URL