-
Notifications
You must be signed in to change notification settings - Fork 12
Flush properly log file on Ctrl+C termination #1030
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
Conversation
|
It is working but i tested it on systemmonitor driver and there is a bug in dmesg parsing. I got: The logger was probably already closed. So, add a check that logger is not None? |
|
OK, thanks for test. I can confirm that if I use duration if crashes (with Ctrl+C it is OK). Your case seems to be related to sudo?? |
|
well, I do not like this hack with multiple calls of close(), but ... if you have any suggestion, please let me know |
|
Maybe add to LogWriter some variable, e.g. |
|
well, |
|
Yes, actually. You can ask if the file is None or not.. |
| def close(self): | ||
| self.f.close() | ||
| self.f = None | ||
| if self.f is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, this is the place where I ask, or maybe I do not understand? (note, that logger is shared among multiple modules)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was move the if to the record. It could be maybe clearer.. but you can ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks
This bug made me crazy for "years" :( ... if you kill some recording with Ctrl+C where there are not many data typically everything was lost (only 16 bytes header was available). This solves the problem (tested with LoRa base-station logger).