From e7ea905c4541be5d440790a10075a994ab5840a6 Mon Sep 17 00:00:00 2001 From: VwCSXg Date: Wed, 27 Jul 2022 22:13:58 +0200 Subject: [PATCH] Added closing logging handlers to __exit__ of engine -> fixes problem with running out of file descriptors (usually after 1024 runs) --- engine.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engine.py b/engine.py index f8734bf..583d683 100644 --- a/engine.py +++ b/engine.py @@ -132,9 +132,11 @@ def __enter__(self): def __exit__(self, exc_type, exc_value, tb): """ - Allows the engine to be used as a context manager; simply stops the engine - if enabled. + Allows the engine to be used as a context manager + Stops the engine if enabled and closes loggers. """ + for handler in self.logger.handlers: + handler.close() if self.enabled: self.shutdown_nfqueue()