X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9856e530871afa8c75fda68ab7cbc718e9ba7e95..7517b29b5a89ec76a328a1e310fa082d6d23e9e0:/src/bindings/python/simgrid_python.cpp diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 1930f15413..96e067bf50 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -89,6 +89,10 @@ PYBIND11_MODULE(simgrid, m) py::register_exception(m, "NetworkFailureException"); py::register_exception(m, "TimeoutException"); + py::register_exception(m, "HostFailureException"); + py::register_exception(m, "StorageFailureException"); + py::register_exception(m, "VmFailureException"); + py::register_exception(m, "CancelException"); /* this_actor namespace */ m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace. See the C++ documentation for details.") @@ -123,8 +127,8 @@ PYBIND11_MODULE(simgrid, m) py::function fun = py::reinterpret_borrow(cb); fun.inc_ref(); // FIXME: why is this needed for tests like actor-kill and actor-lifetime? simgrid::s4u::this_actor::on_exit([fun](bool /*failed*/) { + py::gil_scoped_acquire py_context; // need a new context for callback try { - py::gil_scoped_acquire py_context; // need a new context for callback fun(); } catch (const py::error_already_set& e) { xbt_die("Error while executing the on_exit lambda: %s", e.what()); @@ -205,8 +209,8 @@ PYBIND11_MODULE(simgrid, m) "register_actor", [](Engine* e, const std::string& name, py::object fun_or_class) { e->register_actor(name, [fun_or_class](std::vector args) { + py::gil_scoped_acquire py_context; try { - py::gil_scoped_acquire py_context; /* Convert the std::vector into a py::tuple */ py::tuple params(args.size() - 1); for (size_t i = 1; i < args.size(); i++) @@ -439,8 +443,8 @@ PYBIND11_MODULE(simgrid, m) [](py::object cb) { Host::on_creation_cb([cb](Host& h) { py::function fun = py::reinterpret_borrow(cb); + py::gil_scoped_acquire py_context; // need a new context for callback try { - py::gil_scoped_acquire py_context; // need a new context for callback fun(&h); } catch (const py::error_already_set& e) { xbt_die("Error while executing the on_creation lambda : %s", e.what()); @@ -739,8 +743,8 @@ PYBIND11_MODULE(simgrid, m) fun.inc_ref(); // FIXME: why is this needed for tests like exec-async, exec-dvfs and exec-remote? args.inc_ref(); // FIXME: why is this needed for tests like actor-migrate? return simgrid::s4u::Actor::create(name, h, [fun, args]() { + py::gil_scoped_acquire py_context; try { - py::gil_scoped_acquire py_context; fun(*args); } catch (const py::error_already_set& ex) { if (ex.matches(pyForcefulKillEx)) {