From e77d5475ee10ca38a26b7c8435ac5a3912ea8963 Mon Sep 17 00:00:00 2001 From: Dariusz Suchojad Date: Mon, 28 Oct 2024 11:54:12 +0100 Subject: [PATCH] GH #1069 - Ignore selected locations. --- .../server/file_transfer/observer/base.py | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/code/zato-server/src/zato/server/file_transfer/observer/base.py b/code/zato-server/src/zato/server/file_transfer/observer/base.py index a03a90842..55a4d4316 100644 --- a/code/zato-server/src/zato/server/file_transfer/observer/base.py +++ b/code/zato-server/src/zato/server/file_transfer/observer/base.py @@ -47,6 +47,14 @@ # ################################################################################################################################ # ################################################################################################################################ +# Ignore exceptions coming from locations that include these patterns +path_patters_to_ignore = [ + 'env/bin/python', +] + +# ################################################################################################################################ +# ################################################################################################################################ + class PathCreatedEvent: def __init__(self, src_path:'str', is_dir:'bool') -> 'None': self.src_path = src_path @@ -345,9 +353,20 @@ def observe_with_snapshots( if self.is_local: sleep(timeout) # type: ignore - except Exception: - logger.warning('Exception 2 in %s file observer `%s` e:`%s (%s t:%s)', - self.observer_type_name, path, format_exc(), self.name, self.observer_type_impl) + except Exception as e: + + # Reusable + e_str = str(e) + + # Certain locations should be ignored .. + for item in path_patters_to_ignore: + if item in e_str: + break + + # .. otherwise, we log what happened. + else: + logger.warning('Exception in %s file observer `%s` e:`%s (%s t:%s)', + self.observer_type_name, path, format_exc(), self.name, self.observer_type_impl) if log_stop_event: logger.warning('Stopped %s file transfer observer `%s` for `%s` (snapshot:%s/%s)',