-
-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide defaults for connection pool #1173
Comments
Note that for the problem you've described ("as an HTTPX user, give me a standard import httpx
transport = httpx.init_transport(local_address="0.0.0.0") # Not sure about naming or namespacing here.
client = httpx.Client(transport=transport) There is currently a private method on Lines 541 to 566 in a4463d0
Note how it's basically a static method. We've kept in the I know @tomchristie has been thinking about how HTTPX could expose users more to the concept of transports. So perhaps exposing something equivalent to Edit: I think we can move this discussion to the HTTPX issue tracker. |
Resolved now that |
https://github.com/encode/httpx/blob/master/docs/advanced.md#custom-transports provides an example for configuring an httpx client with a custom connection pool, which is needed to specify a local address. This example is overly complicated and fragile, though, as it requires far too much knowledge about the underlying httpcore interface.
Specifically, if a user wants standard client behavior except for one small thing, that user is required to set a bunch of unrelated client parameters which have no visible defaults, as those defaults would typically be set by the httpx library code. The values of some of these parameters will likely change over time, as will the set of parameters passed by the standard httpx code. So, anything using the custom transport paradigm would either diverge, or the user would need to periodically poll httpx to update to the current set.
In a comment on encode/httpcore#100, I suggested that providing wrappers in httpx around
httpcore.SyncConnectionPool
andhttpcore.AsyncConnectionPool
that merge a set of user-provided configuration options with the defaults, and @tomchristie responded withWe could certainly think about switching our policy on httpcore defaults, yup.
.It would certainly be a lot easier (as well as safer, and more future-proof) if code could do something like:
if they wanted everything to operate as an httpx client normally would, except with a custom local address (that may not be the right interface, but the point is that it doesn't require specifying all of the other things that should be unchanged).
The text was updated successfully, but these errors were encountered: