From 51a5d61bfd6699ab844449698b34befd6a170857 Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 28 Oct 2022 20:39:11 -0500 Subject: [PATCH] Add 1 second buffer to API v2 streaming timeout 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 | 2 +- tweepy/streaming.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index 58eba22..0a943f2 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -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 diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 145f71d..7e77e17 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -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 -- 2.25.1