Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sanitize the prototype of Actor::on_exit() callbacks
[simgrid.git] / src / bindings / python / simgrid_python.cpp
index f9074bf..ca67538 100644 (file)
@@ -13,6 +13,7 @@
 #include <pybind11/stl.h>
 
 #include "src/kernel/context/Context.hpp"
+#include <simgrid/Exception.hpp>
 #include <simgrid/s4u/Actor.hpp>
 #include <simgrid/s4u/Engine.hpp>
 #include <simgrid/s4u/Host.hpp>
@@ -56,8 +57,7 @@ PYBIND11_MODULE(simgrid, m)
   m.attr("simgrid_version") = simgrid_version;
 
   // Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
-  py::object pyForcefulKillEx =
-      py::register_exception<simgrid::kernel::context::ForcefulKillException>(m, "ActorKilled");
+  py::object pyForcefulKillEx = py::register_exception<simgrid::ForcefulKillException>(m, "ActorKilled");
 
   /* this_actor namespace */
   void (*sleep_for_fun)(double) = &simgrid::s4u::this_actor::sleep_for; // pick the right overload
@@ -84,15 +84,13 @@ PYBIND11_MODULE(simgrid, m)
   m2.def("on_exit",
          [](py::object fun) {
            ActorPtr act = Actor::self();
-           simgrid::s4u::this_actor::on_exit(
-               [act, fun](int /*ignored*/, void* /*data*/) {
-                 try {
-                   fun();
-                 } catch (py::error_already_set& e) {
-                   xbt_die("Error while executing the on_exit lambda: %s", e.what());
-                 }
-               },
-               nullptr);
+           simgrid::s4u::this_actor::on_exit([act, fun](bool /*failed*/) {
+             try {
+               fun();
+             } catch (py::error_already_set& e) {
+               xbt_die("Error while executing the on_exit lambda: %s", e.what());
+             }
+           });
          },
          "");