Skip to content

Commit

Permalink
[Python] Regularly flush stdout when printing from C++
Browse files Browse the repository at this point in the history
This prevents excessive output buffering when output is being redirected and the
only source of printing is Cantera's c++ functions, e.g. when running the 1D
solver.
  • Loading branch information
speth committed Dec 15, 2015
1 parent 1c09f7f commit 0703770
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/cantera/cython/wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class PythonLogger : public Cantera::Logger
for (size_t i = 0; i < s.size(); i+=N) {
PySys_WriteStdout("%s", s.substr(i, N).c_str());
}
std::cout.flush();
}

virtual void writeendl() {
PySys_WriteStdout("%s", "\n");
std::cout.flush();
}

virtual void error(const std::string& msg) {
Expand Down

0 comments on commit 0703770

Please sign in to comment.