Skip to content

Commit

Permalink
Make sure the latest detection is stored when process terminates (con…
Browse files Browse the repository at this point in the history
…trolled or uncontrolled)

Signed-off-by: Adam.Dybbroe <a000680@c21856.ad.smhi.se>
  • Loading branch information
Adam.Dybbroe committed Jul 14, 2023
1 parent 02ac292 commit 6d4af54
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion activefires_pp/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,11 @@ def update_fire_detection_id(self):
self._fire_detection_id['counter'] = self._fire_detection_id['counter'] + 1

def save_id_to_file(self):
"""Save the (current) detection id on disk."""
"""Save the (current) detection id on disk.
It is assumed that the user permissions are so that a file can actually
be written to disk here!
"""
with open(self.filepath_detection_id_cache, 'w') as fpt:
id_ = self._create_id_string()
fpt.write(id_)
Expand Down Expand Up @@ -670,6 +674,8 @@ def close(self):
"""Shutdown the Active Fires postprocessing."""
logger.info('Terminating Active Fires post processing.')
self.loop = False
logger.info('Dumping the latest detection id to disk: %s', str(self.filepath_detection_id_cache))
self.save_id_to_file()
try:
self.listener.stop()
except Exception:
Expand Down

0 comments on commit 6d4af54

Please sign in to comment.