From a2395364b05096005998cb815436686ed4fffa7b Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 23 Jan 2021 13:48:01 -0600 Subject: [PATCH] Change Stream._start to _threaded_connect --- tweepy/streaming.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index a494c2e..716b1b7 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -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 -- 2.25.1