Skip to content

Commit

Permalink
ServicePyAdapter::pivot - release GIL, redirect stdout/stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerin Philip committed Jan 25, 2022
1 parent da699f3 commit c51ae04
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bindings/python/bergamot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ class ServicePyAdapter {
std::vector<Response> pivot(Model first, Model second,
std::vector<std::string> &inputs,
const ResponseOptions &options) {
py::scoped_ostream_redirect outstream(
std::cout, // std::ostream&
py::module_::import("sys").attr("stdout") // Python output
);
py::scoped_ostream_redirect errstream(
std::cerr, // std::ostream&
py::module_::import("sys").attr("stderr") // Python output
);

py::call_guard<py::gil_scoped_release> gil_guard;
// Prepare promises, save respective futures. Have callback's in async set
// value to the promises.
std::vector<std::future<Response>> futures;
Expand Down

0 comments on commit c51ae04

Please sign in to comment.