Clients currently share a Tokio runtime, with no way to choose a separate execution environment for a particular client.
I'd like to make this configurable. One use case is high-concurrency HTTP/2: streams on the same connection share mutex-protected state. Running their tasks across many workers can add lock contention and cache migration, so using every available core is not necessarily the best choice for that workload. A client with a dedicated single-thread runtime would let us test and tune this without limiting other clients in the process.
The default should remain a lazily initialized, shared multi-thread runtime. Users could opt into a custom runtime for either the async or blocking client:
from wreq import Client
from wreq.runtime import Runtime
runtime = Runtime(
workers=1,
work_steal=False,
thread_name="http-client",
max_blocking_threads=8,
thread_keep_alive=10.0,
)
client = Client(runtime=runtime)
With work stealing enabled, it provides a multi-thread Tokio runtime. Without work stealing, it provides separate single-thread runtimes. Each client should select one worker when it is created and keep that assignment, rather than choose a random worker for every request. Multiple clients can explicitly share a Runtime.
Clients currently share a Tokio runtime, with no way to choose a separate execution environment for a particular client.
I'd like to make this configurable. One use case is high-concurrency HTTP/2: streams on the same connection share mutex-protected state. Running their tasks across many workers can add lock contention and cache migration, so using every available core is not necessarily the best choice for that workload. A client with a dedicated single-thread runtime would let us test and tune this without limiting other clients in the process.
The default should remain a lazily initialized, shared multi-thread runtime. Users could opt into a custom runtime for either the async or blocking client:
With work stealing enabled, it provides a multi-thread Tokio runtime. Without work stealing, it provides separate single-thread runtimes. Each client should select one worker when it is created and keep that assignment, rather than choose a random worker for every request. Multiple clients can explicitly share a Runtime.