Skip to content

Commit

Permalink
Enhanced retry decorator, to accept a list of exception classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbywater committed May 25, 2017
1 parent 53cb77a commit 7cd5de5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions eventsourcing/domain/model/decorators.py
Expand Up @@ -169,8 +169,13 @@ def wrapper(*args, **kwargs):
else:
# Check decorator args, and return _retry,
# to be called with the decorated function.
if not (isinstance(exc, type) and issubclass(exc, Exception)):
raise TypeError("'exc' must be an exception class: {}".format(exc))
if isinstance(exc, (list, tuple)):
for _exc in exc:
if not (isinstance(_exc, type) and issubclass(_exc, Exception)):
raise TypeError("not an exception class: {}".format(_exc))
else:
if not (isinstance(exc, type) and issubclass(exc, Exception)):
raise TypeError("not an exception class: {}".format(exc))
if not isinstance(max_retries, int):
raise TypeError("'max' must be an int: {}".format(max_retries))
if not isinstance(wait, (float, int)):
Expand Down

0 comments on commit 7cd5de5

Please sign in to comment.