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

Add default timeout #6709

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ dev

- \[Short description of non-trivial change.\]

**Security**
- Add a default timeout value to Requests. The default connect timeout is 10.0
seconds and the default read timeout is 30.0 seconds. (#3070)

2.32.2 (2024-05-21)
-------------------

Expand Down
6 changes: 5 additions & 1 deletion src/requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
preferred_clock = time.time


# (connect timeout, read timeout)
_DEFAULT_TIMEOUT = (10.0, 30.0)


def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
"""Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
Expand Down Expand Up @@ -582,7 +586,7 @@ def request(

# Send the request.
send_kwargs = {
"timeout": timeout,
"timeout": timeout if timeout is not None else _DEFAULT_TIMEOUT,
"allow_redirects": allow_redirects,
}
send_kwargs.update(settings)
Expand Down
Loading