diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index 7f34bb2010f..29cfae9ee7d 100644 --- a/include/pybind11/iostream.h +++ b/include/pybind11/iostream.h @@ -52,9 +52,12 @@ class pythonbuf : public std::streambuf { pywrite(line); pyflush(); + + // Placed inside gil_scoped_aquire as a makeshift mutex + // to reduce MSVC issues + setp(pbase(), epptr()); } - setp(pbase(), epptr()); } return 0; }