Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files open are not closed properly if an exception is raised in Summarize Data #7

Closed
pmithrandir opened this issue Jan 12, 2024 · 0 comments · Fixed by #10
Closed
Assignees

Comments

@pmithrandir
Copy link
Collaborator

In the code we have many of the file openning that are done in this model :
outfile = open(outFilePath, 'w') #dataTime = dateutil.parser.parse(analyser.eventObj['dataTime']) pageData={ 'events': { 'tcSeizures': tcSeizuresLst, 'allSeizures': allSeizuresLst, 'falseAlarms': [], 'otherEvents': [] } } #print(pageData) print("Rendering index page") outfile.write(template.render(data=pageData)) outfile.close()

The problem is that if something is going bad between open and close, the file will never be closed properly.

Using either try except finally of with open(fname) as infile: to resolve that issue.

@pmithrandir pmithrandir changed the title Files open are almost never closed properly if an exception is raised. Files open are not closed properly if an exception is raised in Summarize Data Jan 12, 2024
@pmithrandir pmithrandir self-assigned this Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant