Add timeout to requests calls#617
Add timeout to requests calls#617pixeeai wants to merge 4 commits into
requests calls#617Conversation
|
|
@johnyrahul @muhammad-ali-e @gaya3-zipstack Looks good overall. |
| url = f"{self.base_url}{endpoint}" | ||
| params = {"image_name": image_name, "image_tag": image_tag} | ||
| response = requests.get(url, params=params) | ||
| response = requests.get(url, params=params, timeout=60) |
There was a problem hiding this comment.
Here It might get issue because, some tools need to be run more than 60 seconds. It's better to do with some env variables,
|
NIT: We also need to ensure we catch and handle Timeout exception. FYI we also have such calls made across other repos as well which might need a review too |
|
If there is another repo you have in mind that you'd like for me to scan with pixeebot, feel free to link it here. Thanks, |
What, Why & How
Many developers will be surprised to learn that
requestslibrary 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
timeoutparameter. 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:
More reading
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.
🧚🤖 Powered by Pixeebot