Skip to content
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

Resuse the same Client for connecting to Google DNS #2

Open
freddyaboulton opened this issue Oct 23, 2024 · 2 comments
Open

Resuse the same Client for connecting to Google DNS #2

freddyaboulton opened this issue Oct 23, 2024 · 2 comments

Comments

@freddyaboulton
Copy link

async with httpx.AsyncClient() as client:

We should use a single client instance in this case as it will save us from opening a new connection every time.

@abidlabs
Copy link
Member

I don't think that's possible as the main AsyncClient here:

https://github.com/gradio-app/safefetch/blob/e1343f9ac9fabf65f5f3450dde933fea68bd6cd1/safehttpx/__init__.py#L136

requires passing in the transport, which requires us to have already made the call to the Google DNS to get the IP address

@freddyaboulton
Copy link
Author

I was referring to the client in resolve_hostname_google - it's creating it's own client but I think we can just use the same one esp since we're always connecting to the same host in that function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants