Remove Stream.timeout
authorHarmon <Harmon758@gmail.com>
Sat, 23 Jan 2021 16:48:37 +0000 (10:48 -0600)
committerHarmon <Harmon758@gmail.com>
Sat, 23 Jan 2021 16:48:37 +0000 (10:48 -0600)
Use 90 seconds as the read timeout, per https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting.
Default to using the same 90 seconds for connect timeout.

tweepy/streaming.py

index 8738ae60ca3657c3c8480aa51a6b8ad615c80276..c4099ce829348f34888d17f4ed202f23ca77b251 100644 (file)
@@ -130,7 +130,6 @@ class Stream:
         self.listener = listener
         self.running = False
         self.daemon = options.get("daemon", False)
-        self.timeout = options.get("timeout", 300.0)
         self.retry_count = options.get("retry_count")
 
         # The default socket.read size. Default to less than half the size of
@@ -160,6 +159,7 @@ class Stream:
 
         error_count = 0
         # https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting
+        stall_timeout = 90
         network_error_wait = network_error_wait_step = 0.25
         network_error_wait_max = 16
         http_error_wait = http_error_wait_start = 5
@@ -174,7 +174,7 @@ class Stream:
                 try:
                     with self.session.request(
                         'POST', url, params=params, data=body,
-                        timeout=self.timeout, stream=True, auth=auth,
+                        timeout=stall_timeout, stream=True, auth=auth,
                         verify=self.verify, proxies=self.proxies
                     ) as resp:
                         if resp.status_code != 200: