Method to check for "port is open" based on the URL #2636
Unanswered
jeremyschulman
asked this question in
Ideas
Replies: 1 comment
-
Can't you set a timeout using the import httpx
default_timeout = 40 # for everything else
connect_timeout = 5 # for connection
httpx.get("http://google.com:1337", timeout=httpx.Timeout(default_timeout, connect=connect_timeout)) See the documentation for more information |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As a developer of client libraries that use HTTPX, specifically in asyncio, I find myself writing a function that will check to see if the port is open before attempting a number of API calls. For example if my default timeout is 60 seconds, I do not want the first API call to wait 60s just to tell me that the port is unavailable. As result, I have this code in each of my client libraries.
My feature request would be to add this method to the httpx.AsyncClient.
Thank you for your considerations.
Cheers,
-- Jeremy
Beta Was this translation helpful? Give feedback.
All reactions