Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add timeout to requests calls#1

Merged
pixeeai merged 1 commit into
mainPixee-Bot-Python/Zipstack_unstract:mainfrom
pixeebot/drip-2024-08-21-pixee-python/add-requests-timeoutsPixee-Bot-Python/Zipstack_unstract:pixeebot/drip-2024-08-21-pixee-python/add-requests-timeoutsCopy head branch name to clipboard
Aug 23, 2024
Merged

Add timeout to requests calls#1
pixeeai merged 1 commit into
mainPixee-Bot-Python/Zipstack_unstract:mainfrom
pixeebot/drip-2024-08-21-pixee-python/add-requests-timeoutsPixee-Bot-Python/Zipstack_unstract:pixeebot/drip-2024-08-21-pixee-python/add-requests-timeoutsCopy head branch name to clipboard

Conversation

@pixeebot

@pixeebot pixeebot Bot commented Aug 21, 2024

Copy link
Copy Markdown

Many developers will be surprised to learn that requests library calls do not include timeouts by default. This means that an attempted request could hang indefinitely if no connection is established or if no data is received from the server.

The requests documentation suggests that most calls should explicitly include a timeout parameter. This codemod adds a default timeout value in order to set an upper bound on connection times and ensure that requests connect or fail in a timely manner. This value also ensures the connection will timeout if the server does not respond with data within a reasonable amount of time.

While timeout values will be application dependent, we believe that this codemod adds a reasonable default that serves as an appropriate ceiling for most situations.

Our changes look like the following:

 import requests
 
- requests.get("http://example.com")
+ requests.get("http://example.com", timeout=60)
More reading

I have additional improvements ready for this repo! If you want to see them, leave the comment:

@pixeebot next

... and I will open a new PR right away!

🧚🤖 Powered by Pixeebot

Feedback | Community | Docs | Codemod ID: pixee:python/add-requests-timeouts

@pixeeai

pixeeai commented Aug 23, 2024

Copy link
Copy Markdown

@pixeebot next

@pixeeai pixeeai merged commit 16973e0 into main Aug 23, 2024
@pixeebot pixeebot Bot deleted the pixeebot/drip-2024-08-21-pixee-python/add-requests-timeouts branch August 23, 2024 10:18
@pixeebot

pixeebot Bot commented Aug 23, 2024

Copy link
Copy Markdown
Author

@pixeeai, I opened PR #2, go check it out!

zcarroll4 pushed a commit that referenced this pull request Sep 29, 2024
Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.