-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
Description
If a websocket connection is severed due to network issues for a server restart, a Subscription should automatically reconnect, starting from the most recently processed sequence.
That is, this loop should keep track of the last sequence it has successfully received. On disconnect, it should resume from there using self._connect(start=1 + sequence). Since this can be done seamlessly, it is probably not necessary to log a warning for the user.
Lines 233 to 247 in bdbfe02
| def _receive(self) -> None: | |
| "Blocking loop that receives and processes updates" | |
| while not self._close_event.is_set(): | |
| try: | |
| data_bytes = self._websocket.recv(timeout=RECEIVE_TIMEOUT) | |
| except (TimeoutError, anyio.EndOfStream): | |
| continue | |
| except websockets.exceptions.ConnectionClosedOK: | |
| self._close_event.set() | |
| return | |
| data = msgpack.unpackb(data_bytes) | |
| for ref in self._callbacks: | |
| callback = ref() | |
| if callback is not None: | |
| callback(self, data) |