Skip to content
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

requests.post calls should use timeouts #131

Open
smontanaro opened this issue Jan 21, 2023 · 4 comments
Open

requests.post calls should use timeouts #131

smontanaro opened this issue Jan 21, 2023 · 4 comments

Comments

@smontanaro
Copy link
Contributor

method_call.py and upload.py call requests.post to do their work but don't pass a timeout argument to the call, but should. From the requests documentation:

You can tell Requests to stop waiting for a response after a given number of seconds with the timeout parameter. Nearly all production code should use this parameter in nearly all requests. Failure to do so can cause your program to hang indefinitely:

I did the simplest thing possible, just stuff in a hardcoded timeout of 75s (I was editing my flickr-api installation), but giving the caller a simple API for setting the timeout value would obviously be better. Defaulting to None would preserve the current behavior. I've attached my quick-n-dirty change but will try to work up a more reasonable PR.

timeout.txt

@beaufour
Copy link
Collaborator

I think that's a great idea. It can be much less than 75s imo. 10s would still be pretty conservative.

@smontanaro
Copy link
Contributor Author

Yeah, I was kinda in a hurry and just wanted something I felt would work so I could ignore that issue. The timeout will be settable (see attached).
timeout.txt

@beaufour
Copy link
Collaborator

It would be a lot easier to look at with a pull request :) Globals are quite ugly, but given that there's a precedent with caching it's probably fine.

@smontanaro
Copy link
Contributor Author

Yeah, I understand. Not sure if I can create a pull request without forking your repo. (I'm not much of a git expert.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants