From 3ee7a5acfd8243d8933ae46c0d0846d618fa797c Mon Sep 17 00:00:00 2001 From: Paul van der Linden Date: Mon, 16 Feb 2015 20:54:46 +0000 Subject: [PATCH] fix: new session after closing should honour original headers and params --- tweepy/streaming.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index fda054a..956f29b 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -200,13 +200,17 @@ class Stream(object): self.verify = options.get("verify", True) self.api = API() - self.session = requests.Session() - self.session.headers = options.get("headers") or {} - self.session.params = None + self.headers = options.get("headers") or {} + self.new_session() self.body = None self.retry_time = self.retry_time_start self.snooze_time = self.snooze_time_step + def new_session(self): + self.session = requests.Session() + self.session.headers = self.headers + self.session.params = None + def _run(self): # Authenticate url = "https://%s%s" % (self.host, self.url) @@ -270,7 +274,7 @@ class Stream(object): if resp: resp.close() - self.session = requests.Session() + self.new_session() if exception: # call a handler first so that the exception can be logged. -- 2.25.1