Skip to content

Commit

Permalink
change errorhandling at s3 download
Browse files Browse the repository at this point in the history
  • Loading branch information
SteKrause committed Apr 27, 2023
1 parent 9dab3bd commit 4275f50
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions schulcloud/h5p/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,23 +442,24 @@ def download_object(self, object_key: str, dir_path: str, callback: Optional[Cal
def retry_function(function, params: Dict, max_retries: int):
retries = 0
while retries < max_retries:
print(f'>>>>try1 {function}')
try:
print(f'>>>>try2 {function}')
function(**params)
break
except (ResponseStreamingError, ConnectionResetError, ProtocolError) as error:
print(f'Got Error1: {type(error)}')
print(f'>>>>>>Got Error1: {type(error)}')
if retries == max_retries - 1:
print(f'>>>>>error')
raise error
else:
print(f'retry: {retries} for {function}')
print(f'>>>>>>retry: {retries} for {function}')
retries = retries + 1
except BaseException as error:
print(f'Got Error2: {type(error)}')
print(f'Errortype is ResponseStreamingError: {type(error) is ResponseStreamingError}')
raise error
print(f'>>>>>>Got Error2: {type(error)}')
print(f'>>>>>>Errortype is ResponseStreamingError: {type(error) is ResponseStreamingError}')
if retries == max_retries - 1:
raise error
else:
print(f'retry: {retries} for {function}')
retries = retries + 1


class MetadataNotFoundError(Exception):
Expand Down

0 comments on commit 4275f50

Please sign in to comment.