Bug #9141

[SDKs] Bad use of RetryLoop in events.py

Added by Brett Smith about 4 years ago. Updated about 4 years ago.

Status:
New
Priority:
Normal
Assigned To:
-
Category:
-
Target version:
Start date:
05/04/2016
Due date:
% Done:

0%

Estimated time:
Story points:
-

Description

This is a common idiom in events.py:

for tries_left in RetryLoop(...):
    ...
if tries_left == 0:
    _logger.exception("Everything is terrible")
    ...

There are two bugs in this pattern.

First, if the body of the RetryLoop succeeds on the last attempt, tries_left == 0 will be true, and it will be incorrectly treated as a failure.

Second, no exception is being handled at the time we call _logger.exception(). Testing suggests that in this case, it just writes "None" where it would normally write a traceback. That's not helping anybody, so we should call a different logging method.

Separately from that, there are two times when the body of the RetryLoop is:

                   try:
                        items = self.api.[some method].execute()
                        break
                    except errors.ApiError as error:
                        pass
                    else:
                        tries_left = 0
                        break

break immediately breaks the control flow, so the else: block will never run. Was that supposed to be except Exception: instead?

History

#1 Updated by Brett Smith about 4 years ago

  • Description updated (diff)

#2 Updated by Brett Smith about 4 years ago

  • Target version set to Arvados Future Sprints

Also available in: Atom PDF