Add 1 second buffer to API v2 streaming timeout
authorHarmon <Harmon758@gmail.com>
Sat, 29 Oct 2022 01:39:11 +0000 (20:39 -0500)
committerHarmon <Harmon758@gmail.com>
Sat, 29 Oct 2022 01:39:11 +0000 (20:39 -0500)
The keep-alive is often received after marginally longer than 20 seconds, causing unnecessary timeouts and reconnects with a timeout of exactly 20 seconds

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

index 58eba22c430bf58d2079a9d6ee19069738d7d601..0a943f2f0a8a4296deab62fd760d69a43e0bc925 100644 (file)
@@ -39,7 +39,7 @@ class AsyncBaseStream:
 
     async def _connect(
         self, method, url, params=None, headers=None, body=None,
-        oauth_client=None, timeout=20
+        oauth_client=None, timeout=21
     ):
         error_count = 0
         # https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting
index 145f71dd9ff737eef0bd909c289565cdb96b34f0..7e77e17bf96c81a466533f9d32a24f677561a0ab 100644 (file)
@@ -52,7 +52,7 @@ class BaseStream:
 
     def _connect(
         self, method, url, auth=None, params=None, headers=None, body=None,
-        timeout=20
+        timeout=21
     ):
         self.running = True