From 04edbfee2e5d24daaa9c1d27caaf64c0ef2b86a7 Mon Sep 17 00:00:00 2001 From: simonlju Date: Mon, 11 Mar 2024 09:07:57 +1100 Subject: [PATCH] Add capture exception for CreateLogStream, to avoid flush stuck when CreateLogStream throttle. (#192) --- watchtower/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/watchtower/__init__.py b/watchtower/__init__.py index 0c0a892..f995cf6 100644 --- a/watchtower/__init__.py +++ b/watchtower/__init__.py @@ -370,6 +370,13 @@ def _submit_batch(self, batch, log_stream_name, max_retries=5): # at this point, the first write to the new stream # should not contain a sequence token at all. kwargs.pop("sequenceToken", None) + except Exception as e2: + # Make sure exception in CreateLogStream not exit + # this thread but conitnue to retry + warnings.warn( + "Failed to create log stream {} when delivering log: {}".format(log_stream_name, e2), + WatchtowerWarning, + ) finally: self.creating_log_stream = False else: