Skip to content

Commit

Permalink
Added closing logging handlers to __exit__ of engine
Browse files Browse the repository at this point in the history
-> fixes problem with running out of file descriptors (usually after 1024 runs)
  • Loading branch information
flandweber committed Jul 28, 2022
1 parent e495652 commit e7ea905
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit e7ea905

Please sign in to comment.