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

chore: fresh docstrings for the whole unit audit sites (#1859) · python-zeroconf/python-zeroconf@e5d38b0 · GitHub

Repository navigation

Commit e5d38b0

Browse files
authored
chore: fresh docstrings for the whole unit audit sites (#1859)
1 parent 85e9a87 commit e5d38b0

7 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎src/zeroconf/_cache.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def __init__(self) -> None:
7979
# be run in the event loop.
8080

8181
def _async_add(self, record: _DNSRecord) -> bool:
82+
"""Store a record, returning True when it was not cached before.
83+
84+
Event loop only; not threadsafe.
85+
"""
8286
# Previously storage of records was implemented as a list
8387
# instead a dict. Since DNSRecords are now hashable, the implementation
8488
# uses a dict to ensure that adding a new record to the cache
@@ -157,6 +161,7 @@ def async_add_records(self, entries: Iterable[DNSRecord]) -> bool:
157161
return new
158162

159163
def _async_remove(self, record: _DNSRecord) -> None:
164+
"""Drop a record from the cache. Event loop only; not threadsafe."""
160165
if isinstance(record, DNSService):
161166
service_record = record
162167
_remove_key(self.service_cache, service_record.server_key, service_record)

‎src/zeroconf/_core.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,11 @@ def _add_broadcast_answer( # pylint: disable=no-self-use
563563
out.add_answer_at_time(record, 0)
564564

565565
def unregister_service(self, info: ServiceInfo) -> None:
566+
"""Withdraw a service by broadcasting goodbye records.
567+
568+
May raise EventLoopBlocked when the event loop cannot finish the
569+
withdrawal in time.
570+
"""
566571
assert self.loop is not None
567572
run_coro_with_timeout(
568573
self.async_unregister_service(info),
@@ -571,6 +576,7 @@ def unregister_service(self, info: ServiceInfo) -> None:
571576
)
572577

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

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

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

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

690698
def send(

‎src/zeroconf/_dns.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class DNSQuestionType(enum.Enum):
6464

6565

6666
class DNSEntry: # noqa: PLW1641
67+
"""Identity shared by every question and record: name, type and class."""
68+
6769
__slots__ = ("class_", "key", "name", "type", "unique")
6870

6971
def __init__(self, name: str, type_: int, class_: int) -> None:

‎src/zeroconf/_handlers/record_manager.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def _async_update_matching_records(
195195
self.zc.async_notify_all()
196196

197197
def async_remove_listener(self, listener: RecordUpdateListener) -> None:
198+
"""Detach a record listener; event loop only, not threadsafe."""
198199
try:
199200
self.listeners.remove(listener)
200201
self.zc.async_notify_all()

‎src/zeroconf/_protocol/outgoing.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ def _has_more_to_add(
403403
)
404404

405405
def packets(self) -> list[bytes]:
406+
"""Render the queued sections into wire format chunks and finish the message.
407+
408+
Each chunk stays within _MAX_MSG_TYPICAL, except a lone oversized
409+
answer which may grow to _MAX_MSG_ABSOLUTE and rely on IP
410+
fragmentation.
411+
"""
406412
packets_data = self.packets_data
407413

408414
if self.state == STATE_FINISHED:

‎src/zeroconf/_services/info.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ def _unpack_text_into_properties(self) -> None:
474474
self._properties = properties
475475

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

479480
def _get_ip_addresses_from_cache_lifo(

‎src/zeroconf/asyncio.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ async def async_unregister_all_services(self) -> None:
179179
await self.zeroconf.async_unregister_all_services()
180180

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

184185
async def async_update_service(self, info: ServiceInfo) -> Awaitable:

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL