Commit 974237ef authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Merge streaming improvements from robinhouston.

parents 64935e3c b9556cd5
......@@ -71,11 +71,11 @@ class Stream(object):
self.auth = auth
self.listener = listener
self.running = False
self.timeout = options.get("timeout") or 5.0
self.timeout = options.get("timeout", 300.0)
self.retry_count = options.get("retry_count")
self.retry_time = options.get("retry_time") or 10.0
self.snooze_time = options.get("snooze_time") or 5.0
self.buffer_size = options.get("buffer_size") or 1500
self.retry_time = options.get("retry_time", 10.0)
self.snooze_time = options.get("snooze_time", 5.0)
self.buffer_size = options.get("buffer_size", 1500)
if options.get("secure"):
self.scheme = "https"
else:
......@@ -89,14 +89,13 @@ class Stream(object):
def _run(self):
# Authenticate
url = "%s://%s%s" % (self.scheme, self.host, self.url)
self.auth.apply_auth(url, 'POST', self.headers, self.parameters)
# Connect and process the stream
error_counter = 0
conn = None
exception = None
while self.running:
if self.retry_count and error_counter > self.retry_count:
if self.retry_count is not None and error_counter > self.retry_count:
# quit if error count greater than retry count
break
try:
......@@ -104,6 +103,7 @@ class Stream(object):
conn = httplib.HTTPConnection(self.host)
else:
conn = httplib.HTTPSConnection(self.host)
self.auth.apply_auth(url, 'POST', self.headers, self.parameters)
conn.connect()
conn.sock.settimeout(self.timeout)
conn.request('POST', self.url, self.body, headers=self.headers)
......@@ -207,8 +207,8 @@ class Stream(object):
if locations and len(locations) > 0:
assert len(locations) % 4 == 0
self.parameters['locations'] = ','.join(['%.2f' % l for l in locations])
if count:
self.parameters['count'] = count
if count:
self.parameters['count'] = count
self.body = urllib.urlencode(self.parameters)
self.parameters['delimited'] = 'length'
self._start(async)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment