File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
packages/aws-sdk-signers/src/aws_sdk_signers Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -25,3 +25,12 @@ class Seekable(Protocol):
2525 def seek (self , offset : int , whence : int = 0 , / ) -> int : ...
2626
2727 def tell (self ) -> int : ...
28+
29+
30+ @runtime_checkable
31+ class AsyncSeekable (Protocol ):
32+ """An async file-like object with seek and tell implemented."""
33+
34+ async def seek (self , offset : int , whence : int = 0 , / ) -> int : ...
35+
36+ def tell (self ) -> int : ...
Original file line number Diff line number Diff line change 55import hmac
66import io
77import warnings
8+ from asyncio import iscoroutinefunction
89from collections .abc import AsyncIterable , Iterable
910from copy import deepcopy
1011from hashlib import sha256
1112from typing import Required , TypedDict
1213from urllib .parse import parse_qsl , quote
1314
14- from .interfaces .io import Seekable
15+ from .interfaces .io import AsyncSeekable , Seekable
1516from ._http import URI , AWSRequest , Field
1617from ._identity import AWSCredentialIdentity
1718from ._io import AsyncBytesReader
@@ -757,11 +758,11 @@ async def _compute_payload_hash(
757758 )
758759
759760 checksum = sha256 ()
760- if isinstance (body , Seekable ):
761+ if isinstance (body , AsyncSeekable ) and iscoroutinefunction ( body . seek ):
761762 position = body .tell ()
762763 async for chunk in body :
763764 checksum .update (chunk )
764- body .seek (position )
765+ await body .seek (position )
765766 else :
766767 buffer = io .BytesIO ()
767768 async for chunk in body :
You can’t perform that action at this time.
0 commit comments