@@ -196,14 +196,24 @@ def copy(src_path, dst_path, src_fs=None, dst_fs=None, overwrite=False):
196
196
# create parent directories on local filesystems
197
197
dst_path .parent .makedirs ()
198
198
199
- # copy either within a filesystem or between filesystems
200
- if src_path .fs == dst_path .fs :
201
- src_path .fs .copy (str (src_path ), str (dst_path ))
202
- else :
203
- # read source data first
204
- with src_path .open ("rb" ) as src :
205
- content = src .read ()
206
- # only write to destination if reading source data didn't raise errors,
207
- # otherwise we can end up with empty objects on an object store
208
- with dst_path .open ("wb" ) as dst :
209
- dst .write (content )
199
+ try :
200
+ # copy either within a filesystem or between filesystems
201
+ if src_path .fs == dst_path .fs :
202
+ src_path .fs .copy (str (src_path ), str (dst_path ))
203
+ else :
204
+ # read source data first
205
+ with src_path .open ("rb" ) as src :
206
+ content = src .read ()
207
+ # only write to destination if reading source data didn't raise errors,
208
+ # otherwise we can end up with empty objects on an object store
209
+ with dst_path .open ("wb" ) as dst :
210
+ dst .write (content )
211
+ except Exception as exception : # pragma: no cover
212
+ # This is a hack because some tool using aiohttp does not raise a
213
+ # ClientResponseError directly but masks it as a generic Exception and thus
214
+ # preventing our retry mechanism to kick in.
215
+ if repr (exception ).startswith ('Exception("ClientResponseError' ):
216
+ raise ConnectionError (repr (exception )).with_traceback (
217
+ exception .__traceback__
218
+ ) from exception
219
+ raise
6 commit comments
github-actions[bot] commentedon Dec 3, 2024
missing coverage
github-actions[bot] commentedon Dec 3, 2024
missing coverage
github-actions[bot] commentedon Dec 3, 2024
missing coverage
github-actions[bot] commentedon Dec 3, 2024
missing coverage
github-actions[bot] commentedon Dec 3, 2024
missing coverage
github-actions[bot] commentedon Dec 3, 2024
missing coverage