File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,16 @@ async def _collect_ws_data():
9191
9292 finally :
9393 if websocket :
94- try :
95- await asyncio .shield (self .unsubscribe (websocket ))
96- except asyncio .CancelledError :
97- logging .info ("Unsubscribe completed despite cancellation" )
98- except Exception as e :
99- logging .warning (f"Error during unsubscribe (non-critical): { e !s} " )
100-
94+ # Only try to unsubscribe if connection is still open
95+ if websocket .open :
96+ try :
97+ await asyncio .shield (self .unsubscribe (websocket ))
98+ except asyncio .CancelledError :
99+ logging .info ("Unsubscribe completed despite cancellation" )
100+ except Exception as e :
101+ logging .warning (f"Error during unsubscribe (non-critical): { e !s} " )
102+
103+ # Close can be called even on closed connections (it's idempotent)
101104 try :
102105 await asyncio .shield (websocket .close ())
103106 except asyncio .CancelledError :
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def main() -> None:
2929 setup_environment ()
3030
3131 # Import handler after environment setup
32- from api .read .hyperliquid import handler
32+ from api .read .arbitrum import handler
3333
3434 server = HTTPServer (("localhost" , 8000 ), handler )
3535 print ("Server started at http://localhost:8000" )
You can’t perform that action at this time.
0 commit comments