@@ -452,6 +452,8 @@ def _get_bucket(self, name, throw=False):
452
452
except KeyError :
453
453
try :
454
454
bucket = self .client .get_bucket (name )
455
+ except BrokenPipeError :
456
+ return self ._get_bucket (name , throw )
455
457
except (BadRequest , NotFound ):
456
458
if throw :
457
459
raise
@@ -520,8 +522,11 @@ def _fetch(self, path, content=True):
520
522
tuple(file [Blob], folders list)).
521
523
"""
522
524
if path == "" :
523
- buckets = self .client .list_buckets ()
524
- return True , ([], [b .name + "/" for b in buckets ])
525
+ try :
526
+ buckets = self .client .list_buckets ()
527
+ return True , ([], [b .name + "/" for b in buckets ])
528
+ except BrokenPipeError :
529
+ return self ._fetch (path , content )
525
530
try :
526
531
bucket_name , bucket_path = self ._parse_path (path )
527
532
except ValueError :
@@ -536,15 +541,21 @@ def _fetch(self, path, content=True):
536
541
return True , None
537
542
if bucket_path == "" or bucket_path .endswith ("/" ):
538
543
if bucket_path != "" :
539
- exists = bucket .blob (bucket_path ).exists ()
544
+ try :
545
+ exists = bucket .blob (bucket_path ).exists ()
546
+ except BrokenPipeError :
547
+ return self ._fetch (path , content )
540
548
if exists and not content :
541
549
return True , None
542
550
# blob may not exist but at the same time be a part of a path
543
551
max_list_size = self .max_list_size if content else 1
544
552
try :
545
553
it = bucket .list_blobs (prefix = bucket_path , delimiter = "/" ,
546
554
max_results = max_list_size )
547
- files = list (it )
555
+ try :
556
+ files = list (it )
557
+ except BrokenPipeError :
558
+ return self ._fetch (path , content )
548
559
except NotFound :
549
560
del self ._bucket_cache [bucket_name ]
550
561
return False , None
@@ -553,7 +564,10 @@ def _fetch(self, path, content=True):
553
564
(files , folders ) if content else None )
554
565
if not content :
555
566
return bucket .blob (bucket_path ).exists , None
556
- blob = bucket .get_blob (bucket_path )
567
+ try :
568
+ blob = bucket .get_blob (bucket_path )
569
+ except BrokenPipeError :
570
+ return self ._fetch (path , content )
557
571
return blob is not None , blob
558
572
559
573
def _base_model (self , blob ):
0 commit comments