Skip to content

RequestHandler

veltix.handler.request_handler.RequestHandler

Routes incoming messages, correlates request/response pairs, and dispatches callbacks.

Processing order for each message: 1. Auto-respond to PING with PONG 2. Auto-handle HELLO (client side) — respond with HELLO_ACK 3. Deliver to pending queue if send_and_wait() is waiting 4. Dispatch to a registered route if one matches 5. Fall back to default on_recv callback 6. Log a warning if nothing handled the message

handle

handle(
    response: Response, client=None
) -> Union[Exception, bool]

Handle an incoming message with full routing logic.

Returns True if handled successfully, Exception on unexpected error.

register

register(request_id: bytes) -> Queue

Register a pending request BEFORE sending it.

Avoids the race condition where the response arrives before the queue exists.

wait

wait(
    request_id: bytes, timeout: float = 5.0
) -> Optional[Response]

Wait for a response matching request_id. Must be called after register().

Returns the Response if received within timeout, None otherwise.