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

library: use timeouts #52

Closed
Dobatymo opened this issue Apr 7, 2020 · 4 comments
Closed

library: use timeouts #52

Dobatymo opened this issue Apr 7, 2020 · 4 comments
Assignees

Comments

@Dobatymo
Copy link

Dobatymo commented Apr 7, 2020

Sometimes network calls can block forever if no timeouts are specified. For example here

return requests.post(self.server, data=payload).json()

It would be good if a timeout could be passed to requests.

Maybe it could be specified globally for the client like Client(..., timeout=60) and then use requests.post(..., timeout=self.timeout).

@pawamoy
Copy link
Owner

pawamoy commented Apr 7, 2020

Very good idea 😄

Nice implementation suggestion as well. I'll do this.

Do you think we should put a default timeout? If yes, how many seconds?

@pawamoy pawamoy self-assigned this Apr 7, 2020
@Dobatymo
Copy link
Author

Dobatymo commented Apr 8, 2020

Yes, I think a default timeout would be useful, Probably a long timeout like 60 or 120 seconds. Because users probably don't expect that operations can potentially block forever.
I don't know why requests doesn't use a default timeout. But I think missing timeouts are a common source of errors in network programming.

@pawamoy
Copy link
Owner

pawamoy commented Apr 8, 2020

Thanks, then I'll use a default timeout of 60 seconds.

pawamoy added a commit that referenced this issue Apr 8, 2020
@pawamoy
Copy link
Owner

pawamoy commented Apr 8, 2020

Released in 0.9.0.

You can use the global -T option to set the timeout in floating seconds.

@pawamoy pawamoy closed this as completed Apr 8, 2020
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

No branches or pull requests

2 participants