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

chore: fresh docstrings for the whole unit audit sites by bdraco · Pull Request #1859 · python-zeroconf/python-zeroconf · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (7) 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
5 changes: 5 additions & 0 deletions src/zeroconf/_cache.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 @@ -79,6 +79,10 @@ def __init__(self) -> None:
# be run in the event loop.

def _async_add(self, record: _DNSRecord) -> bool:
"""Store a record, returning True when it was not cached before.

Event loop only; not threadsafe.
"""
# Previously storage of records was implemented as a list
# instead a dict. Since DNSRecords are now hashable, the implementation
# uses a dict to ensure that adding a new record to the cache
Expand Down Expand Up @@ -157,6 +161,7 @@ def async_add_records(self, entries: Iterable[DNSRecord]) -> bool:
return new

def _async_remove(self, record: _DNSRecord) -> None:
"""Drop a record from the cache. Event loop only; not threadsafe."""
if isinstance(record, DNSService):
service_record = record
_remove_key(self.service_cache, service_record.server_key, service_record)
Expand Down
8 changes: 8 additions & 0 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 @@ -563,6 +563,11 @@ def _add_broadcast_answer( # pylint: disable=no-self-use
out.add_answer_at_time(record, 0)

def unregister_service(self, info: ServiceInfo) -> None:
"""Withdraw a service by broadcasting goodbye records.

May raise EventLoopBlocked when the event loop cannot finish the
withdrawal in time.
"""
assert self.loop is not None
run_coro_with_timeout(
self.async_unregister_service(info),
Expand All @@ -571,6 +576,7 @@ def unregister_service(self, info: ServiceInfo) -> None:
)

async def async_unregister_service(self, info: ServiceInfo) -> Awaitable:
"""Withdraw a service from the event loop, broadcasting goodbyes."""
info.set_server_if_missing()
self.registry.async_remove(info)
# If another server uses the same addresses, we do not want to send
Expand Down Expand Up @@ -673,6 +679,7 @@ def add_listener(
self.loop.call_soon_threadsafe(self.record_manager.async_add_listener, listener, question)

def remove_listener(self, listener: RecordUpdateListener) -> None:
"""Detach a record listener from any thread."""
assert self.loop is not None
self.loop.call_soon_threadsafe(self.record_manager.async_remove_listener, listener)

Expand All @@ -685,6 +692,7 @@ def async_add_listener(
self.record_manager.async_add_listener(listener, question)

def async_remove_listener(self, listener: RecordUpdateListener) -> None:
"""Detach a record listener; event loop only, not threadsafe."""
self.record_manager.async_remove_listener(listener)

def send(
Expand Down
2 changes: 2 additions & 0 deletions src/zeroconf/_dns.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 @@ -64,6 +64,8 @@ class DNSQuestionType(enum.Enum):


class DNSEntry: # noqa: PLW1641
"""Identity shared by every question and record: name, type and class."""

__slots__ = ("class_", "key", "name", "type", "unique")

def __init__(self, name: str, type_: int, class_: int) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/zeroconf/_handlers/record_manager.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 @@ -195,6 +195,7 @@ def _async_update_matching_records(
self.zc.async_notify_all()

def async_remove_listener(self, listener: RecordUpdateListener) -> None:
"""Detach a record listener; event loop only, not threadsafe."""
try:
self.listeners.remove(listener)
self.zc.async_notify_all()
Expand Down
6 changes: 6 additions & 0 deletions src/zeroconf/_protocol/outgoing.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 @@ -403,6 +403,12 @@ def _has_more_to_add(
)

def packets(self) -> list[bytes]:
"""Render the queued sections into wire format chunks and finish the message.

Each chunk stays within _MAX_MSG_TYPICAL, except a lone oversized
answer which may grow to _MAX_MSG_ABSOLUTE and rely on IP
fragmentation.
"""
packets_data = self.packets_data

if self.state == STATE_FINISHED:
Expand Down
1 change: 1 addition & 0 deletions src/zeroconf/_services/info.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 @@ -474,6 +474,7 @@ def _unpack_text_into_properties(self) -> None:
self._properties = properties

def get_name(self) -> str:
"""Instance name with the service type stripped."""
return self._name[: len(self._name) - len(self.type) - 1]

def _get_ip_addresses_from_cache_lifo(
Expand Down
1 change: 1 addition & 0 deletions src/zeroconf/asyncio.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 @@ -179,6 +179,7 @@ async def async_unregister_all_services(self) -> None:
await self.zeroconf.async_unregister_all_services()

async def async_unregister_service(self, info: ServiceInfo) -> Awaitable:
"""Withdraw a service, returning an awaitable that completes once the goodbyes are sent."""
return await self.zeroconf.async_unregister_service(info)

async def async_update_service(self, info: ServiceInfo) -> Awaitable:
Expand Down
Loading

Back | FazBrowse Home | New Git URL