import logging
import re
import requests
+import sys
from requests.exceptions import Timeout
from threading import Thread
from time import sleep
# Connect and process the stream
error_counter = 0
resp = None
- exception = None
+ exc_info = None
while self.running:
if self.retry_count is not None:
if error_counter > self.retry_count:
# If it's not time out treat it like any other exception
if isinstance(exc, ssl.SSLError):
if not (exc.args and 'timed out' in str(exc.args[0])):
- exception = exc
+ exc_info = sys.exc_info()
break
if self.listener.on_timeout() is False:
break
self.snooze_time = min(self.snooze_time + self.snooze_time_step,
self.snooze_time_cap)
except Exception as exc:
- exception = exc
+ exc_info = sys.exc_info()
+ print(exc_info)
+ import pdb; pdb.post_mortem(exc_info[2])
# any other exception is fatal, so kill loop
break
self.new_session()
- if exception:
+ if exc_info:
# call a handler first so that the exception can be logged.
- self.listener.on_exception(exception)
- raise exception
+ self.listener.on_exception(exc_info[1])
+ six.reraise(*exc_info)
def _data(self, data):
if self.listener.on_data(data) is False: