-
Notifications
You must be signed in to change notification settings - Fork 42
Add time out to requests calls #4
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
base: main
Are you sure you want to change the base?
Conversation
Update main.py
…ee-python/add-requests-timeouts Add timeout to `requests` calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a timeout parameter to a requests.get() call to prevent the application from hanging indefinitely when fetching the public IP address from an external API.
- Added a 60-second timeout to the requests.get() call for the ipify.org API
hostname = socket.gethostname() | ||
IPAddr = socket.gethostbyname(hostname) | ||
try: | ||
public_ip = get("https://api.ipify.org", timeout=60).text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A 60-second timeout is excessive for a simple IP lookup API call. Consider reducing to 5-10 seconds for better user experience and faster error handling.
public_ip = get("https://api.ipify.org", timeout=60).text | |
public_ip = get("https://api.ipify.org", timeout=5).text |
Copilot uses AI. Check for mistakes.
No description provided.