From 017dfa7efef5c0d84c83179c08633b82bd9a4eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Doll=C3=A9?= Date: Sun, 15 Jun 2014 16:36:20 +0200 Subject: If possible, raise the last exception when stopping When we stop retrying because of recurring exceptions, we expect the decorator to raise the last exception. (if wrap_exception==False) This commit fixes issue #8. --- retrying.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'retrying.py') diff --git a/retrying.py b/retrying.py index b337744..0efd112 100644 --- a/retrying.py +++ b/retrying.py @@ -237,7 +237,10 @@ class Retrying(object): delay_since_first_attempt_ms = int(round(time.time() * 1000)) - start_time if self.stop(attempt_number, delay_since_first_attempt_ms): - raise RetryError(attempt) + if not self._wrap_exception and attempt.has_exception: + raise attempt.get() + else: + raise RetryError(attempt) else: sleep = self.wait(attempt_number, delay_since_first_attempt_ms) time.sleep(sleep / 1000.0) -- cgit v1.2.1