Skip to content

Commit

Permalink
fix: new session after closing should honour original headers and params
Browse files Browse the repository at this point in the history
  • Loading branch information
pvanderlinden committed Feb 16, 2015
1 parent 2e5e6e2 commit 3ee7a5a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tweepy/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ def __init__(self, auth, listener, **options):
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)
Expand Down Expand Up @@ -270,7 +274,7 @@ def _run(self):
if resp:
resp.close()

self.session = requests.Session()
self.new_session()

if exception:
# call a handler first so that the exception can be logged.
Expand Down

0 comments on commit 3ee7a5a

Please sign in to comment.