Persist¶
Maintains a persistent websocket connection.
-
lomond.persist.
persist
(websocket, poll=5, min_wait=5, max_wait=30, ping_rate=30, ping_timeout=None, exit_event=None)¶ Run a websocket, with a retry mechanism and exponential back-off.
Parameters: - websocket – A
Websocket
instance. - poll (float) – The websocket poll rate, in seconds.
- min_wait (float) – The minimum time to wait between reconnect attempts (seconds).
- max_wait (float) – The maximum time to wait between reconnect attempts (seconds).
- ping_rate (float) – Delay between pings (seconds), or 0 for no auto ping.
- ping_timeout (float) – Maximum time in seconds to wait for a pong response before disconnecting. Set to None (default) to disable. If set, double ping_rate would be a good starting point.
- exit_event – A threading event object, which can be used to exit the persist loop if it is set. Set to None to use an internal event object.
- websocket – A
-
lomond.persist.
random
() → x in the interval [0, 1).¶