Skip to content

Commit

Permalink
Unlimited timeout (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor authored Aug 21, 2024
1 parent bacad0c commit b319946
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "ghga_datasteward_kit"
version = "4.1.1"
version = "4.1.2"
description = "GHGA Data Steward Kit - A utils package for GHGA data stewards."
dependencies = [
"crypt4gh >=1.6, <2",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
"Intended Audience :: Developers",
]
name = "ghga_datasteward_kit"
version = "4.1.1"
version = "4.1.2"
description = "GHGA Data Steward Kit - A utils package for GHGA data stewards."
dependencies = [
"crypt4gh >=1.6, <2",
Expand Down
2 changes: 1 addition & 1 deletion src/ghga_datasteward_kit/s3_upload/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class LegacyConfig(S3ObjectStoragesConfig):
default="https://data.ghga.de/.well-known",
description="URL to the root of the WKVS API. Should start with https://.",
)
client_timeout: NonNegativeInt = Field(
client_timeout: NonNegativeInt | None = Field(
default=60, description="Timeout for client requests in seconds"
)
client_num_retries: NonNegativeInt = Field(
Expand Down
2 changes: 1 addition & 1 deletion src/ghga_datasteward_kit/s3_upload/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def send_part(self, part: bytes, part_number: int):
num_retries = HttpxClientConfig.num_retries
timeout = HttpxClientConfig.timeout

while True:
while True and timeout is not None:
LOG.info(
f"Attempting upload of part {part_number} ({len(part)} bytes) with a timeout of {
timeout} seconds."
Expand Down
6 changes: 3 additions & 3 deletions src/ghga_datasteward_kit/s3_upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
class HttpxClientConfig:
"""Helper for user configurable httpx request parameters."""

num_retries: int = 5
timeout: int = 60
num_retries: int
timeout: int | None

@classmethod
def configure(cls, num_retries: int, timeout: int):
def configure(cls, num_retries: int, timeout: int | None):
"""Set timeout in seconds"""
cls.num_retries = num_retries
cls.timeout = timeout
Expand Down
4 changes: 4 additions & 0 deletions tests/test_s3_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ghga_datasteward_kit.s3_upload import Config, LegacyConfig
from ghga_datasteward_kit.s3_upload.entrypoint import async_main, legacy_async_main
from ghga_datasteward_kit.s3_upload.utils import (
HttpxClientConfig,
StorageCleaner,
get_bucket_id,
get_object_storage,
Expand Down Expand Up @@ -53,6 +54,8 @@ async def test_legacy_process(
httpx_mock: HTTPXMock,
):
"""Test whole upload/download process for s3_upload script"""
HttpxClientConfig.configure(num_retries=5, timeout=60)

with S3ContainerFixture() as container:
s3_config = container.s3_config

Expand Down Expand Up @@ -84,6 +87,7 @@ async def test_legacy_process(
@pytest.mark.asyncio
async def test_process(config_fixture: Config, monkeypatch, httpx_mock: HTTPXMock): # noqa: F811
"""Test whole upload/download process for s3_upload script"""
HttpxClientConfig.configure(num_retries=5, timeout=60)

async def secret_exchange_dummy(
*,
Expand Down

0 comments on commit b319946

Please sign in to comment.