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

Default timeout for requests.Session object #2094

Closed
wants to merge 1 commit into from
Closed

Default timeout for requests.Session object #2094

wants to merge 1 commit into from

Conversation

moliware
Copy link

The idea is to have a default timeout for each request you make with a session object.

Example:

>>> import requests
>>> s = requests.Session()
>>> s.timeout = 1
>>> s.get('https://httpbin.org/delay/10')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "requests/sessions.py", line 473, in get
    return self.request('GET', url, **kwargs)
  File "requests/sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
  File "requests/sessions.py", line 564, in send
    r = adapter.send(request, **kwargs)
  File "requests/adapters.py", line 384, in send
    raise Timeout(e, request=request)
requests.exceptions.Timeout: HTTPSConnectionPool(host='httpbin.org', port=443): Read timed out.

I came up with this PR to meet a need of a project based on requests => RedTuna/mysolr#40

Thanks!

@Lukasa
Copy link
Member

Lukasa commented Jun 11, 2014

Thanks for this!

Unfortunately, this is a feature request that comes up often but that we don't have any real interest in. See #2011 for a longer form justification. For this reason, I'm afraid that we can't accept this pull request. Thanks so much for the work though, and please do keep contributing! 🍰

@Lukasa Lukasa closed this Jun 11, 2014
@moliware
Copy link
Author

Thanks for the answer!

@sigmavirus24
Copy link
Contributor

Thanks for all the effort you put in @moliware ! Even though we didn't accept the work, we appreciate your effort to make requests better :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants