Skip to content

Add timeout to requests calls#6

Merged
pixeeai merged 1 commit into
mainfrom
pixeebot/drip-2024-07-09-pixee-python/add-requests-timeouts
Jul 19, 2024
Merged

Add timeout to requests calls#6
pixeeai merged 1 commit into
mainfrom
pixeebot/drip-2024-07-09-pixee-python/add-requests-timeouts

Conversation

@pixeebot
Copy link
Copy Markdown

@pixeebot pixeebot Bot commented Jul 9, 2024

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

🧚🤖 Powered by Pixeebot

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

@pixeebot
Copy link
Copy Markdown
Author

pixeebot Bot commented Jul 17, 2024

I'm confident in this change, but I'm not a maintainer of this project. Do you see any reason not to merge it?

If this change was not helpful, or you have suggestions for improvements, please let me know!

@pixeebot
Copy link
Copy Markdown
Author

pixeebot Bot commented Jul 18, 2024

Just a friendly ping to remind you about this change. If there are concerns about it, we'd love to hear about them!

@pixeeai pixeeai merged commit b358765 into main Jul 19, 2024
@pixeebot pixeebot Bot deleted the pixeebot/drip-2024-07-09-pixee-python/add-requests-timeouts branch July 19, 2024 12:57
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