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

MED-100 Make read_timeout default to None, only use it if set #813

Open
wants to merge 1 commit into
base: master
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
2 changes: 1 addition & 1 deletion medusa-example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ use_sudo_for_restore = True

;aws_cli_path = <Location of the aws cli binary if not in PATH>

; Read timeout in seconds for the storage provider.
; Read timeout in seconds for the storage provider. Not set by default.
;read_timeout = 60

[monitoring]
Expand Down
1 change: 0 additions & 1 deletion medusa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def _build_default_config():
'region': 'default',
'backup_grace_period_in_days': 10,
'use_sudo_for_restore': 'True',
'read_timeout': 60
}

config['logging'] = {
Expand Down
2 changes: 1 addition & 1 deletion medusa/storage/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, config):
logging.getLogger('azure.core.pipeline.policies.http_logging_policy').setLevel(logging.WARNING)
logging.getLogger('chardet.universaldetector').setLevel(logging.WARNING)

self.read_timeout = int(config.read_timeout)
self.read_timeout = int(config.read_timeout) if 'read_timeout' in dir(config) and config.read_timeout else None

super().__init__(config)

Expand Down
6 changes: 3 additions & 3 deletions medusa/storage/google_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, config):

logging.getLogger('gcloud.aio.storage.storage').setLevel(logging.WARNING)

self.read_timeout = int(config.read_timeout)
self.read_timeout = int(config.read_timeout) if 'read_timeout' in dir(config) and config.read_timeout else None

super().__init__(config)

Expand Down Expand Up @@ -158,7 +158,7 @@ async def _download_blob(self, src: str, dest: str):
stream = await self.gcs_storage.download_stream(
bucket=self.bucket_name,
object_name=object_key,
timeout=self.read_timeout if self.read_timeout is not None else -1,
timeout=self.read_timeout,
)
Path(file_path).parent.mkdir(parents=True, exist_ok=True)
with open(file_path, 'wb') as f:
Expand Down Expand Up @@ -243,7 +243,7 @@ async def _read_blob_as_bytes(self, blob: AbstractBlob) -> bytes:
bucket=self.bucket_name,
object_name=blob.name,
session=self.session,
timeout=self.read_timeout if self.read_timeout is not None else -1,
timeout=self.read_timeout,
)
return content

Expand Down
4 changes: 3 additions & 1 deletion medusa/storage/s3_base_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def __init__(self, config):

self.executor = concurrent.futures.ThreadPoolExecutor(int(config.concurrent_transfers))

self.read_timeout = int(config.read_timeout) if 'read_timeout' in dir(config) and config.read_timeout else None

super().__init__(config)

def connect(self):
Expand All @@ -137,7 +139,7 @@ def connect(self):
signature_version='v4',
tcp_keepalive=True,
max_pool_connections=max_pool_size,
read_timeout=int(self.config.read_timeout),
read_timeout=self.read_timeout,
)
if self.credentials.access_key_id is not None:
self.s3_client = boto3.client(
Expand Down
1 change: 1 addition & 0 deletions tests/resources/config/medusa-s3_us_west_oregon.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ concurrent_transfers = 16
backup_grace_period_in_days = 0
max_backup_count = 1
region = us-west-2
read_timeout = 60

[monitoring]
monitoring_provider = local
1 change: 1 addition & 0 deletions tests/storage/abstract_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AttributeDict(dict):
__slots__ = ()
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
__dict__ = dict.__dict__


class TestAbstractStorage(AbstractStorage):
Expand Down
Loading