Skip to content

Commit

Permalink
Merge branch 'release-0.8.2'
Browse files Browse the repository at this point in the history
* release-0.8.2:
  Bumping version to 0.8.2
  Scope awscrt.s3 imports to functions (#293)
  Add changelog for subscribers cache (#292)
  Use lru_cache on costly validation function. (#291)
  • Loading branch information
aws-sdk-python-automation committed Nov 29, 2023
2 parents 3b50c31 + a2a5157 commit 8a32c1f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .changes/0.8.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"category": "Subscribers",
"description": "Added caching for Subscribers to improve throughput by up to 24% in high volume transfer",
"type": "bugfix"
}
]
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
=========

0.8.2
=====

* bugfix:Subscribers: Added caching for Subscribers to improve throughput by up to 24% in high volume transfer


0.8.1
=====

Expand Down
2 changes: 1 addition & 1 deletion s3transfer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __call__(self, bytes_amount):
from s3transfer.exceptions import RetriesExceededError, S3UploadFailedError

__author__ = 'Amazon Web Services'
__version__ = '0.8.1'
__version__ = '0.8.2'


class NullHandler(logging.Handler):
Expand Down
14 changes: 4 additions & 10 deletions s3transfer/crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from io import BytesIO

import awscrt.http
import awscrt.s3
import botocore.awsrequest
import botocore.session
from awscrt.auth import AwsCredentials, AwsCredentialsProvider
Expand All @@ -25,13 +26,7 @@
EventLoopGroup,
TlsContextOptions,
)
from awscrt.s3 import (
S3Client,
S3RequestTlsMode,
S3RequestType,
S3ResponseError,
get_recommended_throughput_target_gbps,
)
from awscrt.s3 import S3Client, S3RequestTlsMode, S3RequestType
from botocore import UNSIGNED
from botocore.compat import urlsplit
from botocore.config import Config
Expand Down Expand Up @@ -124,7 +119,6 @@ def create_s3_crt_client(
use. Specify this argument if you want to use a custom CA cert
bundle instead of the default one on your system.
"""

event_loop_group = EventLoopGroup(num_threads)
host_resolver = DefaultHostResolver(event_loop_group)
bootstrap = ClientBootstrap(event_loop_group, host_resolver)
Expand Down Expand Up @@ -159,7 +153,7 @@ def create_s3_crt_client(

def _get_crt_throughput_target_gbps(provided_throughput_target_bytes=None):
if provided_throughput_target_bytes is None:
target_gbps = get_recommended_throughput_target_gbps()
target_gbps = awscrt.s3.get_recommended_throughput_target_gbps()
logger.debug(
'Recommended CRT throughput target in gbps: %s', target_gbps
)
Expand Down Expand Up @@ -544,7 +538,7 @@ def serialize_http_request(self, transfer_type, future):
return crt_request

def translate_crt_exception(self, exception):
if isinstance(exception, S3ResponseError):
if isinstance(exception, awscrt.s3.S3ResponseError):
return self._translate_crt_s3_response_error(exception)
else:
return None
Expand Down
3 changes: 3 additions & 0 deletions s3transfer/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from functools import lru_cache

from s3transfer.compat import accepts_kwargs
from s3transfer.exceptions import InvalidSubscriberMethodError

Expand All @@ -28,6 +30,7 @@ def __new__(cls, *args, **kwargs):
return super().__new__(cls)

@classmethod
@lru_cache()
def _validate_subscriber_methods(cls):
for subscriber_type in cls.VALID_SUBSCRIBER_TYPES:
subscriber_method = getattr(cls, 'on_' + subscriber_type)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def mock_s3_crt_client():
@pytest.fixture
def mock_get_recommended_throughput_target_gbps():
with mock.patch(
's3transfer.crt.get_recommended_throughput_target_gbps'
'awscrt.s3.get_recommended_throughput_target_gbps'
) as mock_get_target_gbps:
yield mock_get_target_gbps

Expand Down

0 comments on commit 8a32c1f

Please sign in to comment.