Skip to content

Commit

Permalink
Merge pull request #556 from orf/catch-client-payload-error
Browse files Browse the repository at this point in the history
Mark ClientPayloadError as a retryable exception
  • Loading branch information
martindurant committed Nov 18, 2021
2 parents b2c1356 + 094f763 commit 12cb258
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
from s3fs.errors import translate_boto_error
from s3fs.utils import S3BucketRegionCache, ParamKwargsHelper, _get_brange, FileExpired

# ClientPayloadError can be thrown during an incomplete read. aiohttp is a dependency of
# aiobotocore, we guard the import here in case this dependency is replaced in a future version
# of aiobotocore.
try:
from aiohttp import ClientPayloadError
except ImportError:
ClientPayloadError = None


logger = logging.getLogger("s3fs")

Expand All @@ -38,6 +46,9 @@ def setup_logging(level=None):
MANAGED_COPY_THRESHOLD = 5 * 2 ** 30
S3_RETRYABLE_ERRORS = (socket.timeout, IncompleteRead)

if ClientPayloadError is not None:
S3_RETRYABLE_ERRORS += (ClientPayloadError,)

_VALID_FILE_MODES = {"r", "w", "a", "rb", "wb", "ab"}


Expand Down

0 comments on commit 12cb258

Please sign in to comment.