Expand description
Python bindings for the Deribit WebSocket client.
§Design Pattern: Clone and Share State
The WebSocket client must be cloned for async operations because PyO3’s future_into_py
requires 'static futures (cannot borrow from self). To ensure clones share the same
connection state, key fields use Arc<RwLock<T>>:
- Connection mode and signal are shared via Arc.
§Connection Flow
- Clone the client for async operation.
- Connect and populate shared state on the clone.
- Spawn stream handler as background task.
- Return immediately (non-blocking).
§Important Notes
- Never use
block_on()- it blocks the runtime. - Always clone before async blocks for lifetime requirements.