add docstrings

This commit is contained in:
Josh Hawkins
2026-10-14 09:23:31 -05:00
parent 1d7a3a39e6
commit e8c6b6f47d
+8
View File
@@ -482,6 +482,8 @@ class WebSocket(WebSocket_): # type: ignore[misc]
self._aborted = False
def opened(self) -> None:
"""Set a send timeout on the socket and start this client's writer thread."""
# ws4py writes close and pong frames on the shared manager thread, so a
# stalled client must not block sendall forever. SO_SNDTIMEO leaves recv
# (and idle clients) untouched, unlike settimeout().
@@ -497,6 +499,11 @@ class WebSocket(WebSocket_): # type: ignore[misc]
self._writer.start()
def send(self, payload: Any, binary: bool = False) -> None:
"""Queue a message for this client's writer thread.
Returns without waiting for delivery. Disconnects the client if its queue
is full.
"""
try:
self._send_queue.put_nowait((payload, binary))
except queue.Full:
@@ -532,6 +539,7 @@ class WebSocket(WebSocket_): # type: ignore[misc]
pass
def closed(self, code: int, reason: str | None = None) -> None:
"""Signal the writer thread to exit."""
try:
self._send_queue.put_nowait(None)
except queue.Full: