From 24ef670b9eb6cc377d20baba259fb89a51fcc11f Mon Sep 17 00:00:00 2001 From: Baptiste Delpey Date: Mon, 15 Jun 2015 14:42:22 +0200 Subject: [PATCH] fix timeout on accounts with huge transactions number --- modules/paypal/browser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/paypal/browser.py b/modules/paypal/browser.py index 44b15e14..66d32ed3 100644 --- a/modules/paypal/browser.py +++ b/modules/paypal/browser.py @@ -119,7 +119,7 @@ class Paypal(Browser): def get_download_history(self, account, step_min=None, step_max=None): if step_min is None and step_max is None: - step_min = 30 + step_min = 10 step_max = 180 def fetch_fn(start, end): @@ -140,13 +140,13 @@ class Paypal(Browser): Fetches transactions in small chunks to avoid request timeouts. Time period of each requested chunk is adjusted dynamically. """ - FACTOR = 2 + FACTOR = 1.5 step = step_min while end > beginning: start = end - datetime.timedelta(step) chunk = list(fetch_fn(start, end)) end = start - datetime.timedelta(1) - if len(chunk) > 50: + if len(chunk) > 40: # If there're too much transactions in current period, decrease # the period. step = max(step_min, step/FACTOR)