-
Notifications
You must be signed in to change notification settings - Fork 244
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
[Core] Add Process for Flushing Streams #12154
base: master
Are you sure you want to change the base?
Conversation
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.
I would make this part of the analysis stage, see what I did in the CoSim Analysis Stage. I quite like the solution, it is simple yet worked well for me
if self.__flush_stdout: | ||
sys.stdout.flush() | ||
if self.__flush_stderr: | ||
sys.stderr.flush() |
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.
In my experience also a lot of stuff gets stuck in the logger:
Kratos/applications/CoSimulationApplication/python_scripts/co_simulation_analysis.py
Lines 99 to 102 in 245da2c
@staticmethod | |
def Flush(): | |
sys.stdout.flush() | |
KM.Logger.Flush() |
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.
wait, which stream is the logger using? I thought it was writing to stdout.
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.
It depends on how the Logger is constructed. It can use to have std::out
, or std::fstream
or other stream types as well. So using as @philbucher mentioned makes sense.
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.
Kratos/applications/RANSApplication/python_scripts/formulations/utilities.py
Lines 335 to 346 in aacb6c1
def AddFileLoggerOutput(log_file_name): | |
file_logger = Kratos.FileLoggerOutput(log_file_name) | |
default_severity = Kratos.Logger.GetDefaultOutput().GetSeverity() | |
Kratos.Logger.GetDefaultOutput().SetSeverity(Kratos.Logger.Severity.WARNING) | |
Kratos.Logger.AddOutput(file_logger) | |
return default_severity, file_logger | |
def RemoveFileLoggerOutput(default_severity, file_logger): | |
Kratos.Logger.Flush() | |
Kratos.Logger.RemoveOutput(file_logger) | |
Kratos.Logger.GetDefaultOutput().SetSeverity(default_severity) |
fine by me, it's a matter of whether the @KratosMultiphysics/technical-committee is ok with touching |
I'd follow @philbucher 's suggestion as it keeps the "automatic" handling of the flush, which I find is more convenient for the user. |
Nearly every
MainKratos.py
I've ever seen begins by defining anAnalysisStage
that flushesstdout
regularly. In this PR, I'm adding a process that does the same thing to make the main python scripts cleaner.