Skip to content

Commit

Permalink
simplify handle_error
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed May 24, 2023
1 parent 4b796a7 commit 2331341
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/borg/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ def pop_preload_msgid(chunkid):
return msgid

def handle_error(unpacked):
if "exception_class" not in unpacked:
return

error = unpacked["exception_class"]
args = unpacked["exception_args"]

Expand Down Expand Up @@ -687,12 +690,10 @@ def handle_error(unpacked):
try:
unpacked = self.responses.pop(waiting_for[0])
waiting_for.pop(0)
if "exception_class" in unpacked:
handle_error(unpacked)
else:
yield unpacked[RESULT]
if not waiting_for and not calls:
return
handle_error(unpacked)
yield unpacked[RESULT]
if not waiting_for and not calls:
return
except KeyError:
break
if cmd == "async_responses":
Expand All @@ -707,10 +708,8 @@ def handle_error(unpacked):
else:
return
else:
if "exception_class" in unpacked:
handle_error(unpacked)
else:
yield unpacked[RESULT]
handle_error(unpacked)
yield unpacked[RESULT]
if self.to_send or ((calls or self.preload_ids) and len(waiting_for) < MAX_INFLIGHT):
w_fds = [self.stdin_fd]
else:
Expand Down

0 comments on commit 2331341

Please sign in to comment.