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 @@ -628,7 +628,13 @@ def do_register():
628
628
# Make long-polling requests with `get_events`. Once a request
629
629
# has received an answer, pass it to the callback and before
630
630
# making a new long-polling request.
631
- while True :
631
+ # NOTE: Back off exponentially to cover against potential bugs in this
632
+ # library causing a DoS attack against a server when getting errors
633
+ # (explicit values listed for clarity)
634
+ backoff = RandomExponentialBackoff (maximum_retries = 10 ,
635
+ timeout_success_equivalent = 300 ,
636
+ delay_cap = 90 )
637
+ while backoff .keep_going ():
632
638
if queue_id is None :
633
639
(queue_id , last_event_id ) = do_register ()
634
640
@@ -658,12 +664,11 @@ def do_register():
658
664
#
659
665
# Reset queue_id to register a new event queue.
660
666
queue_id = None
661
- # Add a pause here to cover against potential bugs in this library
662
- # causing a DoS attack against a server when getting errors.
663
- # TODO: Make this back off exponentially.
664
- time .sleep (1 )
667
+
668
+ backoff .fail ()
665
669
continue
666
670
671
+ backoff .succeed ()
667
672
for event in res ['events' ]:
668
673
last_event_id = max (last_event_id , int (event ['id' ]))
669
674
callback (event )
You can’t perform that action at this time.
0 commit comments