Skip to content

Commit

Permalink
Merge pull request #517 from nu-radio/fix-nur-writeout
Browse files Browse the repository at this point in the history
fix bug that nur files are not closed properly
  • Loading branch information
cg-laser committed Mar 27, 2023
2 parents cad15d7 + f64c7be commit c508e46
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions NuRadioReco/modules/io/eventWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self):
self.__event_ids_and_runs = None
self.__events_per_file = None
self.__events_in_current_file = 0
self.__fout = None

def __write_fout_header(self):
if self.__number_of_files > 1:
Expand Down Expand Up @@ -301,7 +302,9 @@ def __check_for_duplicate_ids(self, run_number, event_id):
return

def end(self):
if(hasattr(self, "__fout")):
if self.__fout is not None:
self.__fout.close()
self.debug(f"closing file.")
logger.info(f"closing file {self.__filename}.")
else:
logger.warning(f"file {self.__filename} does not exist and won't be closed.")
return self.__number_of_events

0 comments on commit c508e46

Please sign in to comment.