From 7517b29b5a89ec76a328a1e310fa082d6d23e9e0 Mon Sep 17 00:00:00 2001 From: Fabien Chaix Date: Tue, 1 Mar 2022 19:04:20 +0200 Subject: [PATCH] Revert Python stuff but the py_context instantiation change --- src/bindings/python/simgrid_python.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 83d2325d73..96e067bf50 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -84,6 +84,9 @@ PYBIND11_MODULE(simgrid, m) // Swapped contexts are broken, starting from pybind11 v2.8.0. Use thread contexts by default. simgrid::s4u::Engine::set_config("contexts/factory:thread"); + // Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack) + static py::object pyForcefulKillEx(py::register_exception(m, "ActorKilled")); + py::register_exception(m, "NetworkFailureException"); py::register_exception(m, "TimeoutException"); py::register_exception(m, "HostFailureException"); @@ -218,9 +221,9 @@ PYBIND11_MODULE(simgrid, m) if (py::isinstance(res)) res(); } catch (const py::error_already_set& ex) { - if (ex.matches(PyExc_RuntimeError)) { + if (ex.matches(pyForcefulKillEx)) { XBT_VERB("Actor killed"); - simgrid::ForcefulKillException::do_throw(); + simgrid::ForcefulKillException::do_throw(); // Forward that ForcefulKill exception } throw; } @@ -744,9 +747,9 @@ PYBIND11_MODULE(simgrid, m) try { fun(*args); } catch (const py::error_already_set& ex) { - if (ex.matches(PyExc_RuntimeError)) { + if (ex.matches(pyForcefulKillEx)) { XBT_VERB("Actor killed"); - simgrid::ForcefulKillException::do_throw(); + simgrid::ForcefulKillException::do_throw(); // Forward that ForcefulKill exception } throw; } -- 2.20.1