Skip to content

Commit

Permalink
Add 1 second buffer to API v2 streaming timeout
Browse files Browse the repository at this point in the history
The keep-alive is often received after marginally longer than 20 seconds, causing unnecessary timeouts and reconnects with a timeout of exactly 20 seconds
  • Loading branch information
Harmon758 committed Oct 29, 2022
1 parent 0ccfe86 commit 51a5d61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tweepy/asynchronous/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, *, max_retries=inf, proxy=None):

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
Expand Down
2 changes: 1 addition & 1 deletion tweepy/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, *, chunk_size=512, daemon=False, max_retries=inf,

def _connect(
self, method, url, auth=None, params=None, headers=None, body=None,
timeout=20
timeout=21
):
self.running = True

Expand Down

0 comments on commit 51a5d61

Please sign in to comment.