File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -619,7 +619,13 @@ def do_register() -> Tuple[str, int]:
619
619
# Make long-polling requests with `get_events`. Once a request
620
620
# has received an answer, pass it to the callback and before
621
621
# making a new long-polling request.
622
- while True :
622
+ # NOTE: Back off exponentially to cover against potential bugs in this
623
+ # library causing a DoS attack against a server when getting errors
624
+ # (explicit values listed for clarity)
625
+ backoff = RandomExponentialBackoff (maximum_retries = 10 ,
626
+ timeout_success_equivalent = 300 ,
627
+ delay_cap = 90 )
628
+ while backoff .keep_going ():
623
629
if queue_id is None :
624
630
(queue_id , last_event_id ) = do_register ()
625
631
@@ -649,12 +655,11 @@ def do_register() -> Tuple[str, int]:
649
655
#
650
656
# Reset queue_id to register a new event queue.
651
657
queue_id = None
652
- # Add a pause here to cover against potential bugs in this library
653
- # causing a DoS attack against a server when getting errors.
654
- # TODO: Make this back off exponentially.
655
- time .sleep (1 )
658
+
659
+ backoff .fail ()
656
660
continue
657
661
662
+ backoff .succeed ()
658
663
for event in res ['events' ]:
659
664
last_event_id = max (last_event_id , int (event ['id' ]))
660
665
callback (event )
You can’t perform that action at this time.
0 commit comments