Skip to content

Commit

Permalink
BUG: Fixed issue with failing print causing filter to fail (#899)
Browse files Browse the repository at this point in the history
This is a temporary band aid to fix an exception being thrown from python when running through DREAM3D-NX on Windows because std::cout is disabled.

Signed-off-by: Jared Duffey <[email protected]>
  • Loading branch information
JDuffeyBQ authored Mar 29, 2024
1 parent c59e375 commit 5da9e78
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion wrapping/python/CxPybind/CxPybind/CxPybind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,15 @@ std::string MakePythonSignature(std::string_view funcName, const Internals& inte
inline void PyPrintMessage(const IFilter::Message& message)
{
py::gil_scoped_acquire acquireGIL{};
py::print(fmt::format("{}", message.message));
try
{
py::print(fmt::format("{}", message.message));
} catch(const py::error_already_set& pyException)
{
// Can fail when called in a program without stdout (i.e. GUI on Windows)
// Catch the exception to prevent the filter execution from failing
// Should be replaced with the ability to pass in a message handler to the python execute
}
}

inline IFilter::MessageHandler CreatePyMessageHandler()
Expand Down

0 comments on commit 5da9e78

Please sign in to comment.