Skip to content

Commit

Permalink
Per #2830, skip closing of log handlers for METplusConfig objects tha…
Browse files Browse the repository at this point in the history
…t are created for copying values for process list instances so they are not closed before the end of the run.
  • Loading branch information
georgemccabe committed Dec 17, 2024
1 parent 26defe1 commit 229f63d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions metplus/util/config_metplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ def __init__(self, conf=None, run_id=None):
super().__init__(conf)
self._cycle = None
self.run_id = run_id if run_id else str(uuid.uuid4())[0:8]
# if run ID is specified, this is a copy of a config
self.is_copy = run_id is not None
self._logger = logging.getLogger(f'metplus.{self.run_id}')
# config.logger is called in wrappers, so set this name
# so the code doesn't break
Expand All @@ -475,6 +477,9 @@ def __init__(self, conf=None, run_id=None):

def __del__(self):
"""!When object is deleted, close and remove all log handlers"""
# do not close log handlers if this is a copied config object
if self.is_copy:
return
handlers = self.logger.handlers[:]
for handler in handlers:
self.logger.removeHandler(handler)
Expand Down

0 comments on commit 229f63d

Please sign in to comment.