-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
thermald: add function for blocking cloudlog instead of sleep #23489
Conversation
This reverts commit 69289a2.
…llh-blockinginfo
common/logging_extra.py
Outdated
self.info(msg) | ||
# else get_file_handler().emit(msg) | ||
# pass | ||
fd = os.open(fsync_dir, os.O_RDONLY) |
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.
You're probably looking for something like
for h in self.handlers:
h.flush()
However, that also doesn't guarantee the message has been picked up by logmessaged already and has hit disk.
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.
So now I'm adding the file handler which bypasses logmessaged since it uses the filestream, calling handle which calls handle on all the handlers, which emits in all the handlers, but emit for the file_handler is just writing to a filestream and calling flush... then I make sure to fsync the whole directory
Making a blocking cloudlog is quite a bit more complicated than this. I would recommend something simpler for a first contribution. |
Does it have to use logmessaged? In one of the comments it says that you can use the get_file_handler in the case that logmessaged isn't running. This uses SwaglogRotatingFileHandler which can call emit directly, which then calls flush on the file stream. So might just have to make sure to fsync |
Think the cleanest solution is to set the |
perform fsync after cloudlog.info to make sure logs are written to disk before shutdown