Skip to content

Commit e205134

Browse files
tmunzer-AIDEclaude
andcommitted
docs(websockets): clarify ping_timeout derivation and queue_maxsize scope
- note that ping_timeout falls back to 45 when ping_interval=0 (pings disabled, value unused) in the constants comment, README, and all channel class docstrings - document that queue_maxsize bounds both the receive() and callback queues in the channel class docstrings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 844d588 commit e205134

6 files changed

Lines changed: 148 additions & 99 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ All channel classes accept the following optional keyword arguments:
584584
| Parameter | Type | Default | Description |
585585
|-----------|------|---------|-------------|
586586
| `ping_interval` | `int` | `60` | Seconds between automatic ping frames. Set to `0` to disable pings. |
587-
| `ping_timeout` | `int \| None` | `None` | Seconds to wait for a pong response before treating the connection as dead. Defaults to `min(45, ping_interval - 1)`. When `ping_interval > 0`, this must be lower than `ping_interval`. |
587+
| `ping_timeout` | `int \| None` | `None` | Seconds to wait for a pong response before treating the connection as dead. Defaults to `min(45, ping_interval - 1)` when pings are enabled, or `45` when `ping_interval=0` (unused since pings are disabled). When `ping_interval > 0`, this must be lower than `ping_interval`. |
588588
| `auto_reconnect` | `bool` | `False` | Automatically reconnect on transient failures using exponential backoff. |
589589
| `max_reconnect_attempts` | `int` | `5` | Maximum number of reconnect attempts before giving up. |
590590
| `reconnect_backoff` | `float` | `2.0` | Base backoff delay in seconds. Doubles after each failed attempt (2s, 4s, 8s, ...). Resets on successful reconnection. |

src/mistapi/websockets/__ws_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def filter(self, record: logging.LogRecord) -> bool:
5353
MAX_CHANNELS_PER_CONNECTION = 2000
5454
HIGH_CHANNEL_COUNT_WARNING = 1500
5555

56-
# Default pong timeout, and the value ping_timeout is derived from when only
57-
# ping_interval is supplied (min(DEFAULT_PING_TIMEOUT, ping_interval - 1)).
56+
# Default pong timeout. When ping_timeout is not supplied it is derived as
57+
# min(DEFAULT_PING_TIMEOUT, ping_interval - 1), or DEFAULT_PING_TIMEOUT when
58+
# ping_interval is 0 (pings disabled, so the value is unused).
5859
DEFAULT_PING_TIMEOUT = 45
5960

6061

src/mistapi/websockets/location.py

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class BleAssetsEvents(_MistWebsocket):
3333
Interval in seconds to send WebSocket ping frames (keep-alive).
3434
ping_timeout : int | None, default None
3535
Time in seconds to wait for a ping response before considering the
36-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
37-
lower than ping_interval.
36+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
37+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
38+
since pings are disabled). Must be lower than ping_interval when
39+
pings are enabled.
3840
auto_reconnect : bool, default False
3941
Automatically reconnect on unexpected disconnections using exponential backoff.
4042
max_reconnect_attempts : int, default 5
@@ -44,10 +46,11 @@ class BleAssetsEvents(_MistWebsocket):
4446
max_reconnect_backoff : float | None, default None
4547
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
4648
queue_maxsize : int, default 0
47-
Maximum number of messages buffered in the internal queue for the
48-
``receive()`` generator. ``0`` means unbounded. When set,
49-
incoming messages are dropped with a warning when the queue is
50-
full, preventing memory growth on high-frequency streams.
49+
Maximum number of messages buffered in each of the internal queues
50+
used for the ``receive()`` generator and callback delivery. ``0``
51+
means unbounded. When set, incoming messages are dropped with a
52+
warning when the target queue is full, preventing memory growth on
53+
high-frequency streams.
5154
subscription_watchdog_timeout : float, default 10.0
5255
Maximum time in seconds to wait for all channel subscription
5356
acknowledgements after connect. On timeout, the error is reported to
@@ -136,8 +139,10 @@ class ConnectedClientsEvents(_MistWebsocket):
136139
Interval in seconds to send WebSocket ping frames (keep-alive).
137140
ping_timeout : int | None, default None
138141
Time in seconds to wait for a ping response before considering the
139-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
140-
lower than ping_interval.
142+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
143+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
144+
since pings are disabled). Must be lower than ping_interval when
145+
pings are enabled.
141146
auto_reconnect : bool, default False
142147
Automatically reconnect on unexpected disconnections using exponential backoff.
143148
max_reconnect_attempts : int, default 5
@@ -147,10 +152,11 @@ class ConnectedClientsEvents(_MistWebsocket):
147152
max_reconnect_backoff : float | None, default None
148153
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
149154
queue_maxsize : int, default 0
150-
Maximum number of messages buffered in the internal queue for the
151-
``receive()`` generator. ``0`` means unbounded. When set,
152-
incoming messages are dropped with a warning when the queue is
153-
full, preventing memory growth on high-frequency streams.
155+
Maximum number of messages buffered in each of the internal queues
156+
used for the ``receive()`` generator and callback delivery. ``0``
157+
means unbounded. When set, incoming messages are dropped with a
158+
warning when the target queue is full, preventing memory growth on
159+
high-frequency streams.
154160
subscription_watchdog_timeout : float, default 10.0
155161
Maximum time in seconds to wait for all channel subscription
156162
acknowledgements after connect. On timeout, the error is reported to
@@ -239,8 +245,10 @@ class SdkClientsEvents(_MistWebsocket):
239245
Interval in seconds to send WebSocket ping frames (keep-alive).
240246
ping_timeout : int | None, default None
241247
Time in seconds to wait for a ping response before considering the
242-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
243-
lower than ping_interval.
248+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
249+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
250+
since pings are disabled). Must be lower than ping_interval when
251+
pings are enabled.
244252
auto_reconnect : bool, default False
245253
Automatically reconnect on unexpected disconnections using exponential backoff.
246254
max_reconnect_attempts : int, default 5
@@ -250,10 +258,11 @@ class SdkClientsEvents(_MistWebsocket):
250258
max_reconnect_backoff : float | None, default None
251259
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
252260
queue_maxsize : int, default 0
253-
Maximum number of messages buffered in the internal queue for the
254-
``receive()`` generator. ``0`` means unbounded. When set,
255-
incoming messages are dropped with a warning when the queue is
256-
full, preventing memory growth on high-frequency streams.
261+
Maximum number of messages buffered in each of the internal queues
262+
used for the ``receive()`` generator and callback delivery. ``0``
263+
means unbounded. When set, incoming messages are dropped with a
264+
warning when the target queue is full, preventing memory growth on
265+
high-frequency streams.
257266
subscription_watchdog_timeout : float, default 10.0
258267
Maximum time in seconds to wait for all channel subscription
259268
acknowledgements after connect. On timeout, the error is reported to
@@ -342,8 +351,10 @@ class UnconnectedClientsEvents(_MistWebsocket):
342351
Interval in seconds to send WebSocket ping frames (keep-alive).
343352
ping_timeout : int | None, default None
344353
Time in seconds to wait for a ping response before considering the
345-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
346-
lower than ping_interval.
354+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
355+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
356+
since pings are disabled). Must be lower than ping_interval when
357+
pings are enabled.
347358
auto_reconnect : bool, default False
348359
Automatically reconnect on unexpected disconnections using exponential backoff.
349360
max_reconnect_attempts : int, default 5
@@ -353,10 +364,11 @@ class UnconnectedClientsEvents(_MistWebsocket):
353364
max_reconnect_backoff : float | None, default None
354365
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
355366
queue_maxsize : int, default 0
356-
Maximum number of messages buffered in the internal queue for the
357-
``receive()`` generator. ``0`` means unbounded. When set,
358-
incoming messages are dropped with a warning when the queue is
359-
full, preventing memory growth on high-frequency streams.
367+
Maximum number of messages buffered in each of the internal queues
368+
used for the ``receive()`` generator and callback delivery. ``0``
369+
means unbounded. When set, incoming messages are dropped with a
370+
warning when the target queue is full, preventing memory growth on
371+
high-frequency streams.
360372
subscription_watchdog_timeout : float, default 10.0
361373
Maximum time in seconds to wait for all channel subscription
362374
acknowledgements after connect. On timeout, the error is reported to
@@ -447,8 +459,10 @@ class DiscoveredBleAssetsEvents(_MistWebsocket):
447459
Interval in seconds to send WebSocket ping frames (keep-alive).
448460
ping_timeout : int | None, default None
449461
Time in seconds to wait for a ping response before considering the
450-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
451-
lower than ping_interval.
462+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
463+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
464+
since pings are disabled). Must be lower than ping_interval when
465+
pings are enabled.
452466
auto_reconnect : bool, default False
453467
Automatically reconnect on unexpected disconnections using exponential backoff.
454468
max_reconnect_attempts : int, default 5
@@ -458,10 +472,11 @@ class DiscoveredBleAssetsEvents(_MistWebsocket):
458472
max_reconnect_backoff : float | None, default None
459473
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
460474
queue_maxsize : int, default 0
461-
Maximum number of messages buffered in the internal queue for the
462-
``receive()`` generator. ``0`` means unbounded. When set,
463-
incoming messages are dropped with a warning when the queue is
464-
full, preventing memory growth on high-frequency streams.
475+
Maximum number of messages buffered in each of the internal queues
476+
used for the ``receive()`` generator and callback delivery. ``0``
477+
means unbounded. When set, incoming messages are dropped with a
478+
warning when the target queue is full, preventing memory growth on
479+
high-frequency streams.
465480
subscription_watchdog_timeout : float, default 10.0
466481
Maximum time in seconds to wait for all channel subscription
467482
acknowledgements after connect. On timeout, the error is reported to

src/mistapi/websockets/orgs.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ class InsightsEvents(_MistWebsocket):
3131
Interval in seconds to send WebSocket ping frames (keep-alive).
3232
ping_timeout : int | None, default None
3333
Time in seconds to wait for a ping response before considering the
34-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
35-
lower than ping_interval.
34+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
35+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
36+
since pings are disabled). Must be lower than ping_interval when
37+
pings are enabled.
3638
auto_reconnect : bool, default False
3739
Automatically reconnect on unexpected disconnections using exponential backoff.
3840
max_reconnect_attempts : int, default 5
@@ -42,10 +44,11 @@ class InsightsEvents(_MistWebsocket):
4244
max_reconnect_backoff : float | None, default None
4345
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
4446
queue_maxsize : int, default 0
45-
Maximum number of messages buffered in the internal queue for the
46-
``receive()`` generator. ``0`` means unbounded. When set,
47-
incoming messages are dropped with a warning when the queue is
48-
full, preventing memory growth on high-frequency streams.
47+
Maximum number of messages buffered in each of the internal queues
48+
used for the ``receive()`` generator and callback delivery. ``0``
49+
means unbounded. When set, incoming messages are dropped with a
50+
warning when the target queue is full, preventing memory growth on
51+
high-frequency streams.
4952
subscription_watchdog_timeout : float, default 10.0
5053
Maximum time in seconds to wait for all channel subscription
5154
acknowledgements after connect. On timeout, the error is reported to
@@ -130,8 +133,10 @@ class MxEdgesStatsEvents(_MistWebsocket):
130133
Interval in seconds to send WebSocket ping frames (keep-alive).
131134
ping_timeout : int | None, default None
132135
Time in seconds to wait for a ping response before considering the
133-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
134-
lower than ping_interval.
136+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
137+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
138+
since pings are disabled). Must be lower than ping_interval when
139+
pings are enabled.
135140
auto_reconnect : bool, default False
136141
Automatically reconnect on unexpected disconnections using exponential backoff.
137142
max_reconnect_attempts : int, default 5
@@ -141,10 +146,11 @@ class MxEdgesStatsEvents(_MistWebsocket):
141146
max_reconnect_backoff : float | None, default None
142147
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
143148
queue_maxsize : int, default 0
144-
Maximum number of messages buffered in the internal queue for the
145-
``receive()`` generator. ``0`` means unbounded. When set,
146-
incoming messages are dropped with a warning when the queue is
147-
full, preventing memory growth on high-frequency streams.
149+
Maximum number of messages buffered in each of the internal queues
150+
used for the ``receive()`` generator and callback delivery. ``0``
151+
means unbounded. When set, incoming messages are dropped with a
152+
warning when the target queue is full, preventing memory growth on
153+
high-frequency streams.
148154
subscription_watchdog_timeout : float, default 10.0
149155
Maximum time in seconds to wait for all channel subscription
150156
acknowledgements after connect. On timeout, the error is reported to
@@ -229,8 +235,10 @@ class MxEdgesEvents(_MistWebsocket):
229235
Interval in seconds to send WebSocket ping frames (keep-alive).
230236
ping_timeout : int | None, default None
231237
Time in seconds to wait for a ping response before considering the
232-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
233-
lower than ping_interval.
238+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
239+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
240+
since pings are disabled). Must be lower than ping_interval when
241+
pings are enabled.
234242
auto_reconnect : bool, default False
235243
Automatically reconnect on unexpected disconnections using exponential backoff.
236244
max_reconnect_attempts : int, default 5
@@ -240,10 +248,11 @@ class MxEdgesEvents(_MistWebsocket):
240248
max_reconnect_backoff : float | None, default None
241249
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
242250
queue_maxsize : int, default 0
243-
Maximum number of messages buffered in the internal queue for the
244-
``receive()`` generator. ``0`` means unbounded. When set,
245-
incoming messages are dropped with a warning when the queue is
246-
full, preventing memory growth on high-frequency streams.
251+
Maximum number of messages buffered in each of the internal queues
252+
used for the ``receive()`` generator and callback delivery. ``0``
253+
means unbounded. When set, incoming messages are dropped with a
254+
warning when the target queue is full, preventing memory growth on
255+
high-frequency streams.
247256
subscription_watchdog_timeout : float, default 10.0
248257
Maximum time in seconds to wait for all channel subscription
249258
acknowledgements after connect. On timeout, the error is reported to

src/mistapi/websockets/session.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ class SessionWithUrl(_MistWebsocket):
4040
Interval in seconds to send WebSocket ping frames (keep-alive).
4141
ping_timeout : int | None, default None
4242
Time in seconds to wait for a ping response before considering the
43-
connection dead. Defaults to ``min(45, ping_interval - 1)``. Must be
44-
lower than ping_interval.
43+
connection dead. Defaults to ``min(45, ping_interval - 1)`` when
44+
pings are enabled, or ``45`` when ``ping_interval`` is 0 (unused
45+
since pings are disabled). Must be lower than ping_interval when
46+
pings are enabled.
4547
auto_reconnect : bool, default False
4648
Automatically reconnect on unexpected disconnections using exponential backoff.
4749
max_reconnect_attempts : int, default 5
@@ -51,10 +53,11 @@ class SessionWithUrl(_MistWebsocket):
5153
max_reconnect_backoff : float | None, default None
5254
Maximum backoff delay in seconds. If None, backoff grows indefinitely.
5355
queue_maxsize : int, default 0
54-
Maximum number of messages buffered in the internal queue for the
55-
``receive()`` generator. ``0`` means unbounded. When set,
56-
incoming messages are dropped with a warning when the queue is
57-
full, preventing memory growth on high-frequency streams.
56+
Maximum number of messages buffered in each of the internal queues
57+
used for the ``receive()`` generator and callback delivery. ``0``
58+
means unbounded. When set, incoming messages are dropped with a
59+
warning when the target queue is full, preventing memory growth on
60+
high-frequency streams.
5861
subscription_watchdog_timeout : float, default 10.0
5962
Maximum time in seconds to wait for all channel subscription
6063
acknowledgements after connect. On timeout, the error is reported to

0 commit comments

Comments
 (0)