Skip to content

Commit 51a5d61

Browse files
committed
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
1 parent 0ccfe86 commit 51a5d61

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tweepy/asynchronous/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, *, max_retries=inf, proxy=None):
3939

4040
async def _connect(
4141
self, method, url, params=None, headers=None, body=None,
42-
oauth_client=None, timeout=20
42+
oauth_client=None, timeout=21
4343
):
4444
error_count = 0
4545
# https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting

tweepy/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, *, chunk_size=512, daemon=False, max_retries=inf,
5252

5353
def _connect(
5454
self, method, url, auth=None, params=None, headers=None, body=None,
55-
timeout=20
55+
timeout=21
5656
):
5757
self.running = True
5858

0 commit comments

Comments
 (0)