Fix not-stopping on loop
This commit is contained in:
parent
185962ace5
commit
b911caa5af
1 changed files with 6 additions and 3 deletions
|
@ -156,9 +156,12 @@ class WsRouter:
|
|||
async def prediction_forwarder(self):
|
||||
logger.info("Starting prediction forwarder")
|
||||
while self.is_running.is_set():
|
||||
msg = await self.prediction_socket.recv_string()
|
||||
logger.debug(f"Forward prediction message of {len(msg)} chars")
|
||||
WebSocketPredictionHandler.write_to_clients(msg)
|
||||
# timeout so that if no events occur, loop can still stop on is_running
|
||||
has_event = await self.prediction_socket.poll(timeout=1)
|
||||
if has_event:
|
||||
msg = await self.prediction_socket.recv_string()
|
||||
logger.debug(f"Forward prediction message of {len(msg)} chars")
|
||||
WebSocketPredictionHandler.write_to_clients(msg)
|
||||
|
||||
# die together:
|
||||
self.evt_loop.stop()
|
||||
|
|
Loading…
Reference in a new issue