From a0368a506edd0280ef613c6d0c76f1a3c3a7ffbb Mon Sep 17 00:00:00 2001 From: Artem Klintsevich Date: Thu, 8 Jun 2017 21:53:01 -0400 Subject: [PATCH 1/2] Updated Traptor with try catch for ChunkedEncodingError --- traptor/traptor.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/traptor/traptor.py b/traptor/traptor.py index 40bf1bd..beca7dc 100644 --- a/traptor/traptor.py +++ b/traptor/traptor.py @@ -19,6 +19,8 @@ from tenacity import retry, wait_exponential, stop_after_attempt, retry_if_exception_type, wait_chain, wait_fixed from dog_whistle import dw_config, dw_callback +from requests.exceptions import ChunkedEncodingError + from scutils.log_factory import LogFactory from scutils.stats_collector import StatsCollector from traptor_limit_counter import TraptorLimitCounter @@ -1101,8 +1103,17 @@ def run(self): self.restart_flag = False - # Start collecting data - self._main_loop() + try: + # Start collecting data + self._main_loop() + except ChunkedEncodingError as e: + self.logger.error("Ran into a ChunkedEncodingError while processing " + "tweets. Restarting Traptor from top of main process " + "loop", { + 'ex' : traceback.format_exc() + }) + + def main(): From 45395f75b845f262a54edaa7ec9087b0fce460d0 Mon Sep 17 00:00:00 2001 From: Marti Martinez Date: Fri, 9 Jun 2017 10:17:47 -0700 Subject: [PATCH 2/2] re-raise exceptions from main process --- traptor/traptor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traptor/traptor.py b/traptor/traptor.py index beca7dc..a4dd298 100644 --- a/traptor/traptor.py +++ b/traptor/traptor.py @@ -1204,7 +1204,7 @@ def main(): dd_monitoring.increment('traptor_error_occurred', tags=['error_type:traptor_start']) - + raise e if __name__ == '__main__': from raven import Client