Change initial network_error_wait to 0 for streaming
authorHarmon <Harmon758@gmail.com>
Wed, 2 Nov 2022 01:37:56 +0000 (20:37 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 2 Nov 2022 01:37:56 +0000 (20:37 -0500)
Attempt to reconnect immediately when established streaming connection drops

tweepy/asynchronous/streaming.py
tweepy/streaming.py

index 1d520e20e0670ef785244bdd216d7d51051e8a30..0bf6a49767bfc223a6954bcf0e0d51670d48a9d4 100644 (file)
@@ -46,7 +46,8 @@ class AsyncBaseStream:
         # https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting
         # https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/integrate/handling-disconnections
         # https://developer.twitter.com/en/docs/twitter-api/tweets/volume-streams/integrate/handling-disconnections
-        network_error_wait = network_error_wait_step = 0.25
+        network_error_wait = 0
+        network_error_wait_step = 0.25
         network_error_wait_max = 16
         http_error_wait = http_error_wait_start = 5
         http_error_wait_max = 320
@@ -73,7 +74,7 @@ class AsyncBaseStream:
                         if resp.status == 200:
                             error_count = 0
                             http_error_wait = http_error_wait_start
-                            network_error_wait = network_error_wait_step
+                            network_error_wait = 0
 
                             await self.on_connect()
 
index efa56f22fba3e713929eec8bd60be452612f7758..db635bfecd512f4bbffd1318e9b5d022fe6bc13a 100644 (file)
@@ -61,7 +61,8 @@ class BaseStream:
         # https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting
         # https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/integrate/handling-disconnections
         # https://developer.twitter.com/en/docs/twitter-api/tweets/volume-streams/integrate/handling-disconnections
-        network_error_wait = network_error_wait_step = 0.25
+        network_error_wait = 0
+        network_error_wait_step = 0.25
         network_error_wait_max = 16
         http_error_wait = http_error_wait_start = 5
         http_error_wait_max = 320
@@ -80,7 +81,7 @@ class BaseStream:
                         if resp.status_code == 200:
                             error_count = 0
                             http_error_wait = http_error_wait_start
-                            network_error_wait = network_error_wait_step
+                            network_error_wait = 0
 
                             self.on_connect()
                             if not self.running: