Skip to content

Commit

Permalink
support pre 3.10 exception formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rappdw committed Jan 30, 2022
1 parent 6e11201 commit bd2058a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fscrawler/controller/fsapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ def resolve_relationships(self, resolved_relationships: Dict[str, Dict[str, Tupl
coroutines = [self.get_relationships_from_id(resolved_relationships, request) for request in requests]
results = loop.run_until_complete(asyncio.gather(*coroutines, return_exceptions=True))
for result in results:
if result: # no return from get_relationships_from_id, so we have an exception
if result:
# no return from get_relationships_from_id, so we have an exception
# we can tolerate exceptions during relationship resolution... just continue
# processing, but log a warning
logger.warning(traceback.format_exception(result))
if isinstance(result, Exception):
logger.warning(traceback.format_exception(type(result), result, result.__traceback__))
else:
logger.warning(f"Returned unexpected result of type: {type(result)}. Value: {result}")
return
if delay:
time.sleep(delay)
Expand All @@ -200,8 +204,12 @@ def iterate(self, iteration: int, iteration_bound: int, graph: Graph, loop, writ
coroutines = [self.get_persons_from_ids(request, graph, iteration) for request in requests]
results = loop.run_until_complete(asyncio.gather(*coroutines, return_exceptions=True))
for result in results:
if result: # no return from get_relationships_from_id, so we have an exception
raise result
if result:
# no return from get_relationships_from_id, so we have an exception
if isinstance(result, Exception):
raise result
else:
logger.warning(f"Returned unexpected result of type: {type(result)}. Value: {result}")
if iteration_count > PARTIAL_WRITE_THRESHOLD:
iteration_count = 0
writer.checkpoint_iteration(not final_iteration)
Expand Down

0 comments on commit bd2058a

Please sign in to comment.