@@ -573,21 +573,35 @@ def info(
573573 path : AnyFSPath ,
574574 callback : fsspec .Callback = ...,
575575 batch_size : Optional [int ] = ...,
576+ return_exceptions : bool = ...,
576577 ** kwargs ,
577- ) -> "Entry" : ...
578+ ) -> Union [ "Entry" , Exception ] : ...
578579
579580 @overload
580581 def info (
581582 self ,
582583 path : list [AnyFSPath ],
583584 callback : fsspec .Callback = ...,
584585 batch_size : Optional [int ] = ...,
585- ) -> list ["Entry" ]: ...
586+ return_exceptions : bool = ...,
587+ ) -> Union [list ["Entry" ], list [Exception ]]: ...
586588
587- def info (self , path , callback = DEFAULT_CALLBACK , batch_size = None , ** kwargs ):
589+ def info (
590+ self ,
591+ path ,
592+ callback = DEFAULT_CALLBACK ,
593+ batch_size = None ,
594+ return_exceptions = False ,
595+ ** kwargs ,
596+ ):
588597 if isinstance (path , str ):
589- return self .fs .info (path , ** kwargs )
590- callback .set_size (len (path ))
598+ try :
599+ return self .fs .info (path , ** kwargs )
600+ except Exception as e :
601+ if return_exceptions :
602+ return e
603+ raise
604+
591605 jobs = batch_size or self .jobs
592606 if self .fs .async_impl :
593607 loop = get_loop ()
@@ -596,14 +610,22 @@ def info(self, path, callback=DEFAULT_CALLBACK, batch_size=None, **kwargs):
596610 [self .fs ._info (p , ** kwargs ) for p in path ],
597611 batch_size = jobs ,
598612 callback = callback ,
613+ return_exceptions = return_exceptions ,
599614 ),
600615 loop ,
601616 )
602617 return fut .result ()
603618
604- func = partial (self .fs .info , ** kwargs )
619+ def info_func (p ):
620+ try :
621+ return self .fs .info (p , ** kwargs )
622+ except Exception as e :
623+ if return_exceptions :
624+ return e
625+ raise
626+
605627 with ThreadPoolExecutor (max_workers = jobs , cancel_on_error = True ) as executor :
606- it = executor .map (func , path )
628+ it = executor .map (info_func , path )
607629 return list (callback .wrap (it ))
608630
609631 def mkdir (
0 commit comments