beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject [1/2] incubator-beam git commit: Add missing fields to the retry decorator
Date Mon, 21 Nov 2016 21:40:56 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/python-sdk 8e88c7b03 -> 50afc87cd


Add missing fields to the retry decorator


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/88d4da43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/88d4da43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/88d4da43

Branch: refs/heads/python-sdk
Commit: 88d4da43b1acb5098cf40c453bc1ac4fb25f2ca7
Parents: 8e88c7b
Author: Sourabh Bajaj <sourabhbajaj@google.com>
Authored: Mon Nov 21 11:28:56 2016 -0800
Committer: Davor Bonaci <davor@google.com>
Committed: Mon Nov 21 13:40:41 2016 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/utils/retry.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/88d4da43/sdks/python/apache_beam/utils/retry.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/utils/retry.py b/sdks/python/apache_beam/utils/retry.py
index b3016fd..3874c7a 100644
--- a/sdks/python/apache_beam/utils/retry.py
+++ b/sdks/python/apache_beam/utils/retry.py
@@ -117,7 +117,7 @@ def no_retries(fun):
 def with_exponential_backoff(
     num_retries=16, initial_delay_secs=5.0, logger=logging.warning,
     retry_filter=retry_on_server_errors_filter,
-    clock=Clock(), fuzz=True):
+    clock=Clock(), fuzz=True, factor=2, max_delay_secs=60 * 60 * 4):
   """Decorator with arguments that control the retry logic.
 
   Args:
@@ -134,6 +134,11 @@ def with_exponential_backoff(
       use time.sleep().
     fuzz: True if the delay should be fuzzed (default). During testing False
       can be used so that the delays are not randomized.
+    factor: The exponential factor to use on subsequent retries.
+      Default is 2 (doubling).
+    max_delay_sec: Maximum delay (in seconds). After this limit is reached,
+      further tries use max_delay_sec instead of exponentially increasing
+      the time. Defaults to 4 hours.
 
   Returns:
     As per Python decorators with arguments pattern returns a decorator
@@ -155,7 +160,8 @@ def with_exponential_backoff(
     def wrapper(*args, **kwargs):
       retry_intervals = iter(
           FuzzedExponentialIntervals(
-              initial_delay_secs, num_retries, fuzz=0.5 if fuzz else 0))
+              initial_delay_secs, num_retries, factor,
+              fuzz=0.5 if fuzz else 0, max_delay_secs=max_delay_secs))
       while True:
         try:
           return fun(*args, **kwargs)


Mime
View raw message