The desired API would be to use a client as a context manager (even in a stack of context managers) and have the connection pool re-used while the stack is not empty. When the last context manager exits, the connection pool should be closed.
Something like:
client = Client(...)
with client:
response = client.request(...)
with client:
other = client.request(...)
This optimizes IO and allows passing around client instances in various call-stacks while still neatly closing unused resources.
Complication: this should be thread-safe so we can leverage concurrent.futures.ThreadPoolExecutor maximally :grimacing:
The desired API would be to use a client as a context manager (even in a stack of context managers) and have the connection pool re-used while the stack is not empty. When the last context manager exits, the connection pool should be closed.
Something like:
This optimizes IO and allows passing around client instances in various call-stacks while still neatly closing unused resources.
Complication: this should be thread-safe so we can leverage
concurrent.futures.ThreadPoolExecutor
maximally :grimacing: