Change Stream._start to _threaded_connect
authorHarmon <Harmon758@gmail.com>
Sat, 23 Jan 2021 19:48:01 +0000 (13:48 -0600)
committerHarmon <Harmon758@gmail.com>
Sat, 23 Jan 2021 19:48:01 +0000 (13:48 -0600)
tweepy/streaming.py

index a494c2e7adc881cd0d25ee8f40ff3c4d4bf8f7a0..716b1b77192a2e796cc2f1b2415721bd018a25d4 100644 (file)
@@ -225,13 +225,10 @@ class Stream:
             self.session.close()
             self.running = False
 
-    def _start(self, *args, threaded=False, **kwargs):
-        if threaded:
-            self._thread = Thread(target=self._connect, name="Tweepy Stream",
-                                  args=args, kwargs=kwargs, daemon=self.daemon)
-            self._thread.start()
-        else:
-            self._connect(*args, **kwargs)
+    def _threaded_connect(self, *args, **kwargs):
+        self._thread = Thread(target=self._connect, name="Tweepy Stream",
+                              args=args, kwargs=kwargs, daemon=self.daemon)
+        self._thread.start()
 
     def filter(self, follow=None, track=None, threaded=False, locations=None,
                stall_warnings=False, languages=None, filter_level=None):
@@ -254,7 +251,11 @@ class Stream:
             body['language'] = ','.join(map(str, languages))
         if filter_level:
             body['filter_level'] = filter_level
-        self._start(endpoint, body=body, threaded=threaded)
+
+        if threaded:
+            self._threaded_connect(endpoint, body=body)
+        else:
+            self._connect(endpoint, body=body)
 
     def sample(self, threaded=False, languages=None, stall_warnings=False):
         params = {}
@@ -265,7 +266,11 @@ class Stream:
             params['language'] = ','.join(map(str, languages))
         if stall_warnings:
             params['stall_warnings'] = 'true'
-        self._start(endpoint, params=params, threaded=threaded)
+
+        if threaded:
+            self._threaded_connect(endpoint, params=params)
+        else:
+            self._connect(endpoint, params=params)
 
     def disconnect(self):
         self.running = False