Skip to content

Commit

Permalink
Change: Set default timeout for GitHub API to three minutes
Browse files Browse the repository at this point in the history
The httpx default timeout of 5 seconds is very very short for GitHub API
requests. Therefore increase the timeout to some feasible default.
  • Loading branch information
bjoernricks committed Sep 22, 2022
1 parent 084b568 commit 0c8b8db
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 321 deletions.
5 changes: 5 additions & 0 deletions pontos/github/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from pontos.helper import DownloadProgressIterable, download

DEFAULT_GITHUB_API_URL = "https://api.github.com"
DEFAULT_TIMEOUT_CONFIG = httpx.Timeout(180.0) # three minutes


class FileStatus(Enum):
Expand Down Expand Up @@ -62,9 +63,12 @@ def __init__(
self,
token: Optional[str] = None,
url: Optional[str] = DEFAULT_GITHUB_API_URL,
*,
timeout: httpx.Timeout = DEFAULT_TIMEOUT_CONFIG,
) -> None:
self.token = token
self.url = url
self.timeout = timeout

def _request_headers(
self, *, content_type: Optional[str] = None
Expand Down Expand Up @@ -101,6 +105,7 @@ def _request_internal(
headers=headers,
params=params,
follow_redirects=True,
timeout=self.timeout,
**kwargs,
)

Expand Down
Loading

0 comments on commit 0c8b8db

Please sign in to comment.