
This is an automated email from the git hooks/post-receive script. meskio pushed a commit to branch main in repository bridgedb. commit 46127ac1aa32a8ee81aee65b8d847f3bcc7e5ab6 Author: meskio <meskio@torproject.org> AuthorDate: Wed May 18 16:44:20 2022 +0200 Add a delay when retrying to connect to the rdsys backend So we don't fill up the logs with tons of connecting errors. Closes: rdsys#99 --- bridgedb/rdsys.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bridgedb/rdsys.py b/bridgedb/rdsys.py index 0aad902..f6ccd4e 100644 --- a/bridgedb/rdsys.py +++ b/bridgedb/rdsys.py @@ -12,6 +12,7 @@ from bridgedb.bridges import Bridge, MalformedBridgeInfo inter_message_delimiter = b"\r" +max_retry_delay = 60*60 # 1 hour class RdsysProtocol(Protocol): @@ -98,7 +99,20 @@ def start_stream(distributor, token, rdsys_address, hashring): } agent = Agent(reactor) + delay = 1 + + def delayError(err): + nonlocal delay + d = Deferred() + reactor.callLater(delay, d.errback, err) + delay *= 2 + if delay > max_retry_delay: + delay = max_retry_delay + return d + def cbResponse(r): + nonlocal delay + delay = 1 finished = Deferred() r.deliverBody(RdsysProtocol(finished, hashring, distributor)) return finished @@ -118,6 +132,7 @@ def start_stream(distributor, token, rdsys_address, hashring): headers=headers, bodyProducer=body_producer, ) + d.addErrback(delayError) d.addCallback(cbResponse) d.addErrback(lambda err: logging.warning("Error on the connection with rdsys: " + str(err))) d.addCallback(connect) -- To stop receiving notification emails like this one, please contact the administrator of this repository.