From a1ba0d2c404a0842ed72c089fcf70de5a4199e55 Mon Sep 17 00:00:00 2001 From: Panos Athanasiou Date: Wed, 7 Feb 2024 17:02:21 +0100 Subject: [PATCH] add a garbage collector when SfincsAdapter is deleted to make sure that open file handles are closed --- flood_adapt/integrator/sfincs_adapter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flood_adapt/integrator/sfincs_adapter.py b/flood_adapt/integrator/sfincs_adapter.py index 6a9cc07c7..5d208e5c2 100644 --- a/flood_adapt/integrator/sfincs_adapter.py +++ b/flood_adapt/integrator/sfincs_adapter.py @@ -1,3 +1,4 @@ +import gc import logging import os from pathlib import Path @@ -57,6 +58,7 @@ def __del__(self): # Close the log file associated with the logger for handler in self.sfincs_logger.handlers: handler.close() + gc.collect() def set_timing(self, event: EventModel): """Changes model reference times based on event time series."""