mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-15 11:12:49 +03:00
add docstrings
This commit is contained in:
@@ -482,6 +482,8 @@ class WebSocket(WebSocket_): # type: ignore[misc]
|
|||||||
self._aborted = False
|
self._aborted = False
|
||||||
|
|
||||||
def opened(self) -> None:
|
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
|
# ws4py writes close and pong frames on the shared manager thread, so a
|
||||||
# stalled client must not block sendall forever. SO_SNDTIMEO leaves recv
|
# stalled client must not block sendall forever. SO_SNDTIMEO leaves recv
|
||||||
# (and idle clients) untouched, unlike settimeout().
|
# (and idle clients) untouched, unlike settimeout().
|
||||||
@@ -497,6 +499,11 @@ class WebSocket(WebSocket_): # type: ignore[misc]
|
|||||||
self._writer.start()
|
self._writer.start()
|
||||||
|
|
||||||
def send(self, payload: Any, binary: bool = False) -> None:
|
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:
|
try:
|
||||||
self._send_queue.put_nowait((payload, binary))
|
self._send_queue.put_nowait((payload, binary))
|
||||||
except queue.Full:
|
except queue.Full:
|
||||||
@@ -532,6 +539,7 @@ class WebSocket(WebSocket_): # type: ignore[misc]
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def closed(self, code: int, reason: str | None = None) -> None:
|
def closed(self, code: int, reason: str | None = None) -> None:
|
||||||
|
"""Signal the writer thread to exit."""
|
||||||
try:
|
try:
|
||||||
self._send_queue.put_nowait(None)
|
self._send_queue.put_nowait(None)
|
||||||
except queue.Full:
|
except queue.Full:
|
||||||
|
|||||||
Reference in New Issue
Block a user