Python Client: Is set_auth() thread-safe for concurrent requests?
I'm building a FastAPI backend that serves multiple concurrent users. To optimize Convex WebSocket connection overhead (~400-600ms per
new connection), I want to reuse a single ConvexClient instance across requests and call set_auth(user_token) per-request.
Current Setup:
Question:
Is ConvexClient.set_auth(token) thread-safe in the Python client (v0.7.0)?
Specifically:
• If Request A calls set_auth(token_A) followed by Request B calling set_auth(token_B) before A's query executes, will A's query use the
correct token?
• Does set_auth() mutate shared connection-level state, or is auth tracked per-query somehow?
What I'm seeing:
• Per-request clients work but have high latency (965ms per query)
• Shared client would reduce latency, but I need to confirm data isolation between users
What I'd like:
Either confirmation that shared client + per-request set_auth() is safe, OR recommended approach for connection pooling in multi-threaded
Python environments.
Thanks!
──────────────────────────────────────────
• Python client: 0.7.0
• Python: 3.13
