Skip to content

Commit

Permalink
Change initial network_error_wait to 0 for streaming
Browse files Browse the repository at this point in the history
Attempt to reconnect immediately when established streaming connection drops
  • Loading branch information
Harmon758 committed Nov 2, 2022
1 parent bb934fc commit b18c1a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tweepy/asynchronous/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ async def _connect(
# 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
Expand All @@ -73,7 +74,7 @@ async def _connect(
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()

Expand Down
5 changes: 3 additions & 2 deletions tweepy/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def _connect(
# 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
Expand All @@ -80,7 +81,7 @@ def _connect(
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:
Expand Down

0 comments on commit b18c1a6

Please sign in to comment.