Skip to content

Commit

Permalink
Feat/increate request timeout for upload (#1519)
Browse files Browse the repository at this point in the history
* feat: increase request timeout for upload

* change download timeout

* fix lint
  • Loading branch information
paaragon authored Oct 22, 2024
1 parent eb05950 commit 0d09fcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/qiskit_serverless/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# request timeout
REQUESTS_TIMEOUT: int = 30
REQUESTS_STREAMING_TIMEOUT: int = 60
REQUESTS_TIMEOUT_OVERRIDE = "REQUESTS_TIMEOUT_OVERRIDE"

# gateway
Expand Down
9 changes: 6 additions & 3 deletions client/qiskit_serverless/core/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
from opentelemetry import trace
from tqdm import tqdm

from qiskit_serverless.core.constants import REQUESTS_TIMEOUT
from qiskit_serverless.core.constants import (
REQUESTS_STREAMING_TIMEOUT,
REQUESTS_TIMEOUT,
)
from qiskit_serverless.utils.json import safe_json_request


Expand Down Expand Up @@ -67,7 +70,7 @@ def download(
params={"file": file, "provider": provider},
stream=True,
headers={"Authorization": f"Bearer {self._token}"},
timeout=REQUESTS_TIMEOUT,
timeout=REQUESTS_STREAMING_TIMEOUT,
) as req:
req.raise_for_status()

Expand Down Expand Up @@ -95,7 +98,7 @@ def upload(self, file: str, provider: Optional[str] = None) -> Optional[str]:
data={"provider": provider},
stream=True,
headers={"Authorization": f"Bearer {self._token}"},
timeout=REQUESTS_TIMEOUT,
timeout=REQUESTS_STREAMING_TIMEOUT,
) as req:
if req.ok:
return req.text
Expand Down

0 comments on commit 0d09fcb

Please sign in to comment.