Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions common/metric_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ async def _collect_ws_data():

finally:
if websocket:
try:
await asyncio.shield(self.unsubscribe(websocket))
except asyncio.CancelledError:
logging.info("Unsubscribe completed despite cancellation")
except Exception as e:
logging.warning(f"Error during unsubscribe (non-critical): {e!s}")

# Only try to unsubscribe if connection is still open
if websocket.open:
try:
await asyncio.shield(self.unsubscribe(websocket))
except asyncio.CancelledError:
logging.info("Unsubscribe completed despite cancellation")
except Exception as e:
logging.warning(f"Error during unsubscribe (non-critical): {e!s}")

# Close can be called even on closed connections (it's idempotent)
try:
await asyncio.shield(websocket.close())
except asyncio.CancelledError:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main() -> None:
setup_environment()

# Import handler after environment setup
from api.read.hyperliquid import handler
from api.read.arbitrum import handler

server = HTTPServer(("localhost", 8000), handler)
print("Server started at http://localhost:8000")
Expand Down