Commit 0ffb9506 authored by Dorian Roly's avatar Dorian Roly Committed by Vincent A

[bred] total_offset in history to avoid infinite loop and less max requests

It seems that, in certain cases, the loop can be infinite when the
website is returning the transactions endlessly.

total_offset is here to block the while. If an account has more than
100 000 transactions, they will not have older transactions.
Because of the total_offset that previously was at 100 000 which led
at 4000 request max, I've decided to reduce the total_offset max to
50 000, halving the number of requests.
parent fef831dc
......@@ -280,6 +280,7 @@ class BredBrowser(LoginBrowser, StatesMixin):
today =
seen = set()
offset = 0
total_transactions = 0
next_page = True
end_date =
last_date = None
......@@ -309,10 +310,11 @@ class BredBrowser(LoginBrowser, StatesMixin):
next_page = len(transactions) > 0
offset += 50
total_transactions += 50
# This assert supposedly prevents infinite loops,
# but some customers actually have a lot of transactions.
assert offset < 100000, 'the site may be doing an infinite loop'
assert total_transactions < 50000, 'the site may be doing an infinite loop'
def iter_investments(self, account):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment