From b18c1a6239e81cb5744fa99d392ec539de787e5c Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 1 Nov 2022 20:37:56 -0500 Subject: [PATCH] Change initial network_error_wait to 0 for streaming Attempt to reconnect immediately when established streaming connection drops --- tweepy/asynchronous/streaming.py | 5 +++-- tweepy/streaming.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index 1d520e2..0bf6a49 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -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() diff --git a/tweepy/streaming.py b/tweepy/streaming.py index efa56f2..db635bf 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -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: -- 2.25.1