@@ -32,25 +32,25 @@ async def fetch_intersection_data(api_url: str = Config.get_api_url()) -> None:
3232 None. Puts MonitoringData objects into the UI update queue.
3333 """
3434 try :
35+ logger .info (f"Connecting to WebSocket API at { api_url } " )
3536 async for websocket in websocket_connect (api_url , max_size = 100_000_000 ):
36- try :
37- async for message in websocket :
38- raw_data : dict = json .loads (message )
39- traffic_data : Optional [MonitoringData ] = await parse_api_response (raw_data )
40- # Put data into the queue for the UI to consume
41- await ui_update_queue .put (traffic_data )
42- except WebsocketsConnectionClosed as e :
43- logger .warning (f"WebSocket connection closed by server: { str (e )} " )
44- await asyncio .sleep (3 )
45- except WebSocketException as e :
46- logger .error (f"WebSocket error: { str (e )} " )
47- await asyncio .sleep (3 )
48-
37+ async for message in websocket :
38+ raw_data : dict = json .loads (message )
39+ traffic_data : Optional [MonitoringData ] = await parse_api_response (raw_data )
40+ # Put data into the queue for the UI to consume
41+ await ui_update_queue .put (traffic_data )
42+ except WebsocketsConnectionClosed as e :
43+ logger .warning (f"WebSocket connection closed by server: { str (e )} " )
44+ await asyncio .sleep (3 )
45+ except WebSocketException as e :
46+ logger .error (f"WebSocket error: { str (e )} " )
47+ await asyncio .sleep (3 )
4948 except json .JSONDecodeError as e :
5049 logger .error ("Received invalid JSON data from WebSocket" )
5150 raise e
5251 except Exception as e :
5352 logger .error (f"Error Connecting to WebSocket: { str (e )} ." )
53+ await asyncio .sleep (3 )
5454
5555async def update_components (debug_mode = False ):
5656 """
0 commit comments