Uh oh!
There was an error while loading. Please reload this page.
Redesign client for more flexibility via direct httpx access - #775
Conversation
Codecov Report
@@ Coverage Diff @@## main #775 +/- ##
=========================================
Coverage 100.00% 100.00% =========================================
Files 49 49 Lines 1971 1971 =========================================
Hits 1971 1971
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
dbanty
commented
Jul 3, 2023
This should now be mostly functional, there are definitely some breaking changes in here though. I'd love for folks to take a look around and see if there's anything to improve |
emann
left a comment
There was a problem hiding this comment.
One fixed typo in a docstring, other than that looking good!
One suggestion would be to potentially define either a protocol or just a type union e.g. ClientT = Union[Client, AuthenticatedClient] so that type hinting of "clients" is a bit cleaner, especially if for some reason we add a third client type down the line. May be overkill but would be aesthetically pleasing haha
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Ethan Mann <emannguitar@gmail.com>
dbanty
commented
Jul 7, 2023
I think we're going to move to dynamically generating clients based on any security schemes defined (rather than the generic, often incorrect, This probably requires some more thought, though, to get the interfaces right 🤔 |
dbanty
commented
Jul 8, 2023
Going to give this a week to marinate in case any of the authors of various issues I've mentioned this in want to give feedback. |
httpx accessThere was a problem hiding this comment.
Those are awesome changes IMO 🎉 Thanks so much @dbanty, and sorry for having a look so late. I mostly went through the generated e2e and integration tests, they look great. Only left one minor comment about customizing the (Authenticated)Client implementation.
Uh oh!
There was an error while loading. Please reload this page.
tasn
commented
Jul 23, 2023
Thanks for all the work getting this off the ground, but I have one concern from reading the changelog which I may have not understood correctly. |
dbanty
commented
Jul 26, 2023
@tasn it really depends on what you're doing 😅. For long-lived clients (i.e., you're reusing the client for many requests), this change will be much more efficient by default as it will reuse TCP connections via connection pooling. For short-lived processes (e.g., a Python script that runs for a few seconds or minutes and then ends), it doesn't matter much if you're not cleaning up, because when the process exits, the connections will be closed. So, while best practice is to close connections either via a context manager or by manually calling So, when do you need to worry (and thus, why did I put warnings in the changelog)? If you have a long lived Python process which creates many clients, each new client will create a new TCP connection. Eventually, if these are not cleaned up, you will run out of available ports on your underlying operating system. Garbage collection doesn't seem to help here, so this could be a big problem. Imagine you have a web server where, for each incoming request, it creates a new So to recap, if you're already keeping a single
|
Closes#118, #202, #491, #532, #745, #773, #775
TODO
base_url(and similar) duplication requirement