Skip to content

Commit c2bdf55

Browse files
committed
Increase default read timeout to 10 seconds
The read timeout is the time until Github starts the response to an http request. The current default of one second can be too short for a local maybe slower Github Enterprise. Instead change it to 10s as github suggests also in its best practices for request from Github to integrations [1]. [1] https://developer.github.com/v3/guides/best-practices-for-integrators/#favor-asynchronous-work-over-synchronous
1 parent 5deccee commit c2bdf55

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/github3/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class GitHubSession(requests.Session):
9393
"two_factor_auth_cb",
9494
]
9595

96-
def __init__(self, default_connect_timeout=4, default_read_timeout=1):
96+
def __init__(self, default_connect_timeout=4, default_read_timeout=10):
9797
"""Slightly modify how we initialize our session."""
9898
super(GitHubSession, self).__init__()
9999
self.default_connect_timeout = default_connect_timeout

tests/unit/test_github_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_default_timeout(self, request_mock):
4141
assert r is response
4242
request_mock.assert_called_once_with(
4343
"GET", "http://example.com", allow_redirects=True,
44-
timeout=(4, 1)
44+
timeout=(4, 10)
4545
)
4646

4747
@mock.patch.object(requests.Session, 'request')
@@ -149,7 +149,7 @@ def test_request_ignores_responses_that_do_not_require_2fa(
149149
assert r is response
150150
request_mock.assert_called_once_with(
151151
"GET", "http://example.com", allow_redirects=True,
152-
timeout=(4, 1)
152+
timeout=(4, 10)
153153
)
154154

155155
@mock.patch.object(requests.Session, "request")

0 commit comments

Comments
 (0)