Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Python: Add platform-failures example, and extend Py to make it work
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Jan 2022 09:38:18 +0000 (10:38 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Jan 2022 09:40:59 +0000 (10:40 +0100)
MANIFEST.in
examples/python/CMakeLists.txt
examples/python/app-masterworkers/app-masterworkers.py
examples/python/platform-failures/platform-failures.py [new file with mode: 0644]
examples/python/platform-failures/platform-failures.tesh [new file with mode: 0644]
examples/python/platform-failures/platform-failures_d.xml [new file with mode: 0644]
src/bindings/python/simgrid_python.cpp

index 02cbfc1..7ba1b9a 100644 (file)
@@ -532,6 +532,8 @@ include examples/python/io-degradation/io-degradation.py
 include examples/python/io-degradation/io-degradation.tesh
 include examples/python/network-nonlinear/network-nonlinear.py
 include examples/python/network-nonlinear/network-nonlinear.tesh
+include examples/python/platform-failures/platform-failures.py
+include examples/python/platform-failures/platform-failures.tesh
 include examples/python/platform-profile/platform-profile.py
 include examples/python/platform-profile/platform-profile.tesh
 include examples/smpi/NAS/DGraph.c
@@ -2033,6 +2035,7 @@ include examples/python/CMakeLists.txt
 include examples/python/actor-create/actor-create_d.xml
 include examples/python/actor-lifetime/actor-lifetime_d.xml
 include examples/python/app-masterworkers/app-masterworkers_d.xml
+include examples/python/platform-failures/platform-failures_d.xml
 include examples/smpi/CMakeLists.txt
 include examples/smpi/NAS/CMakeLists.txt
 include examples/smpi/comm_dynamic_costs/CMakeLists.txt
index f1692ef..0ad9767 100644 (file)
@@ -2,7 +2,7 @@ foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate ac
         app-masterworkers
         comm-wait comm-waitall comm-waitany
         exec-async exec-basic exec-dvfs exec-remote
-        platform-profile
+        platform-profile platform-failures
         network-nonlinear clusters-multicpu io-degradation exec-cpu-nonlinear)
   set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
   set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.py)
@@ -22,4 +22,6 @@ endforeach()
 set(examples_src  ${examples_src}                                                      PARENT_SCOPE)
 set(tesh_files    ${tesh_files}   examples/python/actor-create/actor-create_d.xml
                                   examples/python/actor-lifetime/actor-lifetime_d.xml
-                                  examples/python/app-masterworkers/app-masterworkers_d.xml  PARENT_SCOPE)
+                                  examples/python/app-masterworkers/app-masterworkers_d.xml
+                                  examples/python/platform-failures/platform-failures_d.xml
+                                  PARENT_SCOPE)
index 200d818..f6b1902 100644 (file)
@@ -12,9 +12,7 @@ import sys
 
 # master-begin
 def master(*args):
-  if len(args) < 2:
-    raise AssertionError(
-            f"Actor master requires 3 parameters plus the workers' names, but got only {len(args)}")
+  assert len(args) > 3, f"Actor master requires 3 parameters plus the workers' names, but got {len(args)}"
   tasks_count = int(args[0])
   compute_cost = int(args[1])
   communicate_cost = int(args[2])
diff --git a/examples/python/platform-failures/platform-failures.py b/examples/python/platform-failures/platform-failures.py
new file mode 100644 (file)
index 0000000..0574352
--- /dev/null
@@ -0,0 +1,112 @@
+## Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the license (GNU LGPL) which comes with this package.
+from simgrid import Actor, Comm, Engine, Host, Mailbox, this_actor, NetworkFailureException, TimeoutException
+import sys
+
+# This example shows how to work with the state profile of a host or a link,
+# specifying when the resource must be turned on or off.
+#
+# To set such a profile, the first way is to use a file in the XML, while the second is to use the programmatic
+# interface, as exemplified in the main() below. Once this profile is in place, the resource will automatically
+# be turned on and off.
+#
+# The actors running on a host that is turned off are forcefully killed
+# once their on_exit callbacks are executed. They cannot avoid this fate.
+# Since we specified on_failure="RESTART" for each actors in the XML file,
+# they will be automatically restarted when the host starts again.
+#
+# Communications using failed links will .. fail.
+
+def master(* args):
+  assert len(args) == 4, f"Actor master requires 4 parameters, but got {len(args)} ones."
+  tasks_count   = int(args[0])
+  comp_size     = int(args[1])
+  comm_size     = int(args[2])
+  workers_count = int(args[3])
+
+  this_actor.info(f"Got {workers_count} workers and {tasks_count} tasks to process")
+
+  for i in range(tasks_count): # For each task to be executed: 
+    # - Select a worker in a round-robin way
+    mailbox = Mailbox.by_name(f"worker-{i % workers_count}")
+    try:
+      this_actor.info(f"Send a message to {mailbox.name}")
+      mailbox.put(comp_size, comm_size, 10.0)
+      this_actor.info(f"Send to {mailbox.name} completed")
+    except TimeoutException:
+      this_actor.info(f"Mmh. Got timeouted while speaking to '{mailbox.name}'. Nevermind. Let's keep going!")
+    except NetworkFailureException:
+      this_actor.info(f"Mmh. The communication with '{mailbox.name}' failed. Nevermind. Let's keep going!")
+
+  this_actor.info("All tasks have been dispatched. Let's tell everybody the computation is over.")
+  for i in range (workers_count):
+    # - Eventually tell all the workers to stop by sending a "finalize" task
+    mailbox = Mailbox.by_name(f"worker-{i % workers_count}")
+    try:
+      mailbox.put(-1.0, 0, 1.0)
+    except TimeoutException:
+      this_actor.info(f"Mmh. Got timeouted while speaking to '{mailbox.name}'. Nevermind. Let's keep going!")
+    except NetworkFailureException:
+      this_actor.info(f"Mmh. The communication with '{mailbox.name}' failed. Nevermind. Let's keep going!")
+
+  this_actor.info("Goodbye now!")
+
+def worker(* args):
+  assert len(args) == 1, "Expecting one parameter"
+  id               = int(args[0])
+
+  mailbox = Mailbox.by_name(f"worker-{id}")
+  done = False
+  while not done:
+    try:
+      this_actor.info(f"Waiting a message on {mailbox.name}")
+      compute_cost = mailbox.get()
+      if compute_cost > 0: # If compute_cost is valid, execute a computation of that cost 
+        this_actor.info("Start execution...")
+        this_actor.execute(compute_cost)
+        this_actor.info("Execution complete.")
+      else: # Stop when receiving an invalid compute_cost
+        this_actor.info("I'm done. See you!")
+        done = True
+    except NetworkFailureException:
+      this_actor.info("Mmh. Something went wrong. Nevermind. Let's keep going!")
+
+def sleeper():
+  this_actor.info("Start sleeping...")
+  this_actor.sleep_for(1)
+  this_actor.info("done sleeping.")
+
+if __name__ == '__main__':
+  assert len(sys.argv) > 2, f"Usage: python app-masterworkers.py platform_file deployment_file"
+
+  e = Engine(sys.argv)
+
+  # This is how to attach a profile to an host that is created from the XML file.
+  # This should be done before calling load_platform(), as the on_creation() event is fired when loading the platform.
+  # You can never set a new profile to a resource that already have one.
+  def on_creation(host):
+    if (host.name == "Bourrassa"):
+      host.set_state_profile("67 0\n70 1\n", 0)
+  Host.on_creation_cb(on_creation)
+
+  e.load_platform(sys.argv[1])
+
+  e.register_actor("master", master)
+  e.register_actor("worker", worker)
+  e.load_deployment(sys.argv[2])
+
+  # Add a new host programatically, and attach a state profile to it
+  lili = e.get_netzone_root().create_host("Lilibeth", 1e15)
+  lili.set_state_profile("4 0\n5 1\n", 10)
+  lili.seal()
+
+  # Create an actor on that new host, to monitor its own state
+  actor = Actor.create("sleeper", lili, sleeper)
+  actor.set_auto_restart(True)
+
+  e.run()
+
+  this_actor.info(f"Simulation time {e.get_clock():.4f}")
diff --git a/examples/python/platform-failures/platform-failures.tesh b/examples/python/platform-failures/platform-failures.tesh
new file mode 100644 (file)
index 0000000..35bcba0
--- /dev/null
@@ -0,0 +1,116 @@
+#!/usr/bin/env tesh
+
+p Testing a simple master/workers example application handling failures
+
+! output sort 19
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/platform-failures.py ${platfdir}/small_platform_failures.xml ${srcdir:=.}/platform-failures_d.xml --log=xbt_cfg.thres:critical --log=no_loc --cfg=path:${srcdir} --cfg=network/crosstraffic:0 "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" --log=res_cpu.t:verbose
+> [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
+> [  0.000000] (0:maestro@) Deployment includes some initially turned off Hosts ... nevermind.
+> [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
+> [  0.000000] (1:master@Tremblay) Send a message to worker-0
+> [  0.000000] (7:sleeper@Lilibeth) Start sleeping...
+> [  0.010309] (1:master@Tremblay) Send to worker-0 completed
+> [  0.010309] (2:worker@Tremblay) Start execution...
+> [  0.000000] (2:worker@Tremblay) Waiting a message on worker-0
+> [  0.000000] (3:worker@Jupiter) Waiting a message on worker-1
+> [  0.000000] (5:worker@Ginette) Waiting a message on worker-3
+> [  0.000000] (6:worker@Bourassa) Waiting a message on worker-4
+> [  0.010309] (1:master@Tremblay) Send a message to worker-1
+> [  1.000000] (0:maestro@) Restart actors on host Fafard
+> [  1.000000] (8:worker@Fafard) Waiting a message on worker-2
+> [  1.000000] (1:master@Tremblay) Mmh. The communication with 'worker-1' failed. Nevermind. Let's keep going!
+> [  1.000000] (1:master@Tremblay) Send a message to worker-2
+> [  2.000000] (1:master@Tremblay) Mmh. The communication with 'worker-2' failed. Nevermind. Let's keep going!
+> [  2.000000] (0:maestro@) Restart actors on host Jupiter
+> [  2.000000] (1:master@Tremblay) Send a message to worker-3
+> [  2.000000] (9:worker@Jupiter) Waiting a message on worker-1
+> [  2.010309] (2:worker@Tremblay) Execution complete.
+> [  2.010309] (2:worker@Tremblay) Waiting a message on worker-0
+> [  3.030928] (1:master@Tremblay) Send to worker-3 completed
+> [  3.030928] (1:master@Tremblay) Send a message to worker-4
+> [  3.030928] (5:worker@Ginette) Start execution...
+> [  4.061856] (1:master@Tremblay) Send to worker-4 completed
+> [  4.061856] (1:master@Tremblay) Send a message to worker-0
+> [  4.061856] (6:worker@Bourassa) Start execution...
+> [  4.072165] (1:master@Tremblay) Send to worker-0 completed
+> [  4.072165] (1:master@Tremblay) Send a message to worker-1
+> [  4.072165] (2:worker@Tremblay) Start execution...
+> [  5.000000] (0:maestro@) Restart actors on host Lilibeth
+> [  5.000000] (10:sleeper@Lilibeth) Start sleeping...
+> [  5.030928] (5:worker@Ginette) Execution complete.
+> [  5.030928] (5:worker@Ginette) Waiting a message on worker-3
+> [  5.103093] (1:master@Tremblay) Send to worker-1 completed
+> [  5.103093] (1:master@Tremblay) Send a message to worker-2
+> [  5.103093] (9:worker@Jupiter) Start execution...
+> [  6.000000] (10:sleeper@Lilibeth) done sleeping.
+> [  6.061856] (6:worker@Bourassa) Execution complete.
+> [  6.061856] (6:worker@Bourassa) Waiting a message on worker-4
+> [  6.072165] (2:worker@Tremblay) Execution complete.
+> [  6.072165] (2:worker@Tremblay) Waiting a message on worker-0
+> [  7.103093] (9:worker@Jupiter) Execution complete.
+> [  7.103093] (9:worker@Jupiter) Waiting a message on worker-1
+> [ 15.103093] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
+> [ 15.103093] (1:master@Tremblay) Send a message to worker-3
+> [ 15.103093] (1:master@Tremblay) Mmh. The communication with 'worker-3' failed. Nevermind. Let's keep going!
+> [ 15.103093] (1:master@Tremblay) Send a message to worker-4
+> [ 15.103093] (5:worker@Ginette) Mmh. Something went wrong. Nevermind. Let's keep going!
+> [ 15.103093] (5:worker@Ginette) Waiting a message on worker-3
+> [ 16.134021] (1:master@Tremblay) Send to worker-4 completed
+> [ 16.134021] (1:master@Tremblay) Send a message to worker-0
+> [ 16.134021] (6:worker@Bourassa) Start execution...
+> [ 16.144330] (1:master@Tremblay) Send to worker-0 completed
+> [ 16.144330] (1:master@Tremblay) Send a message to worker-1
+> [ 16.144330] (2:worker@Tremblay) Start execution...
+> [ 17.175258] (1:master@Tremblay) Send to worker-1 completed
+> [ 17.175258] (1:master@Tremblay) Send a message to worker-2
+> [ 17.175258] (9:worker@Jupiter) Start execution...
+> [ 18.134021] (6:worker@Bourassa) Execution complete.
+> [ 18.134021] (6:worker@Bourassa) Waiting a message on worker-4
+> [ 18.144330] (2:worker@Tremblay) Execution complete.
+> [ 18.144330] (2:worker@Tremblay) Waiting a message on worker-0
+> [ 19.175258] (9:worker@Jupiter) Execution complete.
+> [ 19.175258] (9:worker@Jupiter) Waiting a message on worker-1
+> [ 20.000000] (0:maestro@) Restart actors on host Lilibeth
+> [ 20.000000] (11:sleeper@Lilibeth) Start sleeping...
+> [ 21.000000] (11:sleeper@Lilibeth) done sleeping.
+> [ 27.175258] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
+> [ 27.175258] (1:master@Tremblay) Send a message to worker-3
+> [ 28.206186] (1:master@Tremblay) Send to worker-3 completed
+> [ 28.206186] (1:master@Tremblay) Send a message to worker-4
+> [ 28.206186] (1:master@Tremblay) Mmh. The communication with 'worker-4' failed. Nevermind. Let's keep going!
+> [ 28.206186] (1:master@Tremblay) Send a message to worker-0
+> [ 28.206186] (5:worker@Ginette) Start execution...
+> [ 28.206186] (6:worker@Bourassa) Mmh. Something went wrong. Nevermind. Let's keep going!
+> [ 28.206186] (6:worker@Bourassa) Waiting a message on worker-4
+> [ 28.216495] (1:master@Tremblay) Send to worker-0 completed
+> [ 28.216495] (1:master@Tremblay) Send a message to worker-1
+> [ 28.216495] (2:worker@Tremblay) Start execution...
+> [ 29.247423] (1:master@Tremblay) Send to worker-1 completed
+> [ 29.247423] (1:master@Tremblay) Send a message to worker-2
+> [ 29.247423] (9:worker@Jupiter) Start execution...
+> [ 30.206186] (5:worker@Ginette) Execution complete.
+> [ 30.206186] (5:worker@Ginette) Waiting a message on worker-3
+> [ 30.216495] (2:worker@Tremblay) Execution complete.
+> [ 30.216495] (2:worker@Tremblay) Waiting a message on worker-0
+> [ 31.247423] (9:worker@Jupiter) Execution complete.
+> [ 31.247423] (9:worker@Jupiter) Waiting a message on worker-1
+> [ 35.000000] (0:maestro@) Restart actors on host Lilibeth
+> [ 35.000000] (12:sleeper@Lilibeth) Start sleeping...
+> [ 36.000000] (12:sleeper@Lilibeth) done sleeping.
+> [ 39.247423] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
+> [ 39.247423] (1:master@Tremblay) Send a message to worker-3
+> [ 40.278351] (1:master@Tremblay) Send to worker-3 completed
+> [ 40.278351] (1:master@Tremblay) Send a message to worker-4
+> [ 40.278351] (5:worker@Ginette) Start execution...
+> [ 41.309278] (1:master@Tremblay) Send to worker-4 completed
+> [ 41.309278] (1:master@Tremblay) All tasks have been dispatched. Let's tell everybody the computation is over.
+> [ 41.309278] (2:worker@Tremblay) I'm done. See you!
+> [ 41.309278] (6:worker@Bourassa) Start execution...
+> [ 41.309278] (9:worker@Jupiter) I'm done. See you!
+> [ 42.309278] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-2'. Nevermind. Let's keep going!
+> [ 43.309278] (0:maestro@) Simulation time 43.3093
+> [ 43.309278] (1:master@Tremblay) Mmh. Got timeouted while speaking to 'worker-3'. Nevermind. Let's keep going!
+> [ 43.309278] (1:master@Tremblay) Goodbye now!
+> [ 43.309278] (6:worker@Bourassa) Execution complete.
+> [ 43.309278] (6:worker@Bourassa) Waiting a message on worker-4
+> [ 43.309278] (6:worker@Bourassa) I'm done. See you!
\ No newline at end of file
diff --git a/examples/python/platform-failures/platform-failures_d.xml b/examples/python/platform-failures/platform-failures_d.xml
new file mode 100644 (file)
index 0000000..894ff51
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+  <!-- The master actor (with some arguments) -->
+  <actor host="Tremblay" function="master">
+    <argument value="20"/>       <!-- Number of tasks -->
+    <argument value="50000000"/>  <!-- Computation size of tasks -->
+    <argument value="1000000"/>   <!-- Communication size of tasks -->
+    <argument value="5"/>         <!-- Number of workers -->
+  </actor>
+  <!-- The worker actors (with mailbox to listen on as argument) -->
+  <actor host="Tremblay" function="worker" on_failure="RESTART">
+    <argument value="0"/>
+  </actor>
+  <actor host="Jupiter" function="worker" on_failure="RESTART">
+    <argument value="1"/>
+  </actor>
+  <actor host="Fafard" function="worker" on_failure="RESTART">
+    <argument value="2"/>
+  </actor>
+  <actor host="Ginette" function="worker" on_failure="RESTART">
+    <argument value="3"/>
+  </actor>
+  <actor host="Bourassa" function="worker" on_failure="RESTART">
+    <argument value="4"/>
+  </actor>
+</platform>
index 5d99033..dbfa0f7 100644 (file)
@@ -47,6 +47,7 @@ using simgrid::s4u::Actor;
 using simgrid::s4u::ActorPtr;
 using simgrid::s4u::Engine;
 using simgrid::s4u::Host;
+using simgrid::s4u::Link;
 using simgrid::s4u::Mailbox;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(python, "python");
@@ -86,6 +87,9 @@ PYBIND11_MODULE(simgrid, m)
   // Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
   static py::object pyForcefulKillEx(py::register_exception<simgrid::ForcefulKillException>(m, "ActorKilled"));
 
+  py::register_exception<simgrid::NetworkFailureException>(m, "NetworkFailureException");
+  py::register_exception<simgrid::TimeoutException>(m, "TimeoutException");
+
   /* this_actor namespace */
   m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace. See the C++ documentation for details.")
       .def(
@@ -115,7 +119,8 @@ PYBIND11_MODULE(simgrid, m)
       .def("exit", &simgrid::s4u::this_actor::exit, py::call_guard<py::gil_scoped_release>(), "kill the current actor")
       .def(
           "on_exit",
-          [](py::object fun) {
+          [](py::object cb) {
+            py::function fun = py::reinterpret_borrow<py::function>(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*/) {
               try {
@@ -264,7 +269,7 @@ PYBIND11_MODULE(simgrid, m)
       .def(
           "route_to",
           [](simgrid::s4u::Host* h, simgrid::s4u::Host* to) {
-            auto* list = new std::vector<simgrid::s4u::Link*>();
+            auto* list = new std::vector<Link*>();
             double bw  = 0;
             h->route_to(to, *list, &bw);
             return make_tuple(list, bw);
@@ -347,7 +352,22 @@ PYBIND11_MODULE(simgrid, m)
       .def_property_readonly(
           "available_speed", &Host::get_available_speed,
           "Get the available speed ratio, between 0 and 1.\n"
-          "This accounts for external load (see :py:func:`set_speed_profile() <simgrid.Host.set_speed_profile>`).");
+          "This accounts for external load (see :py:func:`set_speed_profile() <simgrid.Host.set_speed_profile>`).")
+      .def(
+          "on_creation_cb",
+          [](py::object cb) {
+            Host::on_creation_cb([cb](Host& h) {
+              py::function fun = py::reinterpret_borrow<py::function>(cb);
+              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());
+              }
+            });
+          },
+          py::call_guard<py::gil_scoped_release>(), "");
+
   py::enum_<simgrid::s4u::Host::SharingPolicy>(host, "SharingPolicy")
       .value("NONLINEAR", simgrid::s4u::Host::SharingPolicy::NONLINEAR)
       .value("LINEAR", simgrid::s4u::Host::SharingPolicy::LINEAR)
@@ -385,19 +405,19 @@ PYBIND11_MODULE(simgrid, m)
       netpoint(m, "NetPoint", "NetPoint object");
 
   /* Class Link */
-  py::class_<simgrid::s4u::Link, std::unique_ptr<simgrid::s4u::Link, py::nodelete>> link(
-      m, "Link", "Network link. See the C++ documentation for details.");
-  link.def("set_latency", py::overload_cast<const std::string&>(&simgrid::s4u::Link::set_latency),
+  py::class_<Link, std::unique_ptr<Link, py::nodelete>> link(m, "Link",
+                                                             "Network link. See the C++ documentation for details.");
+  link.def("set_latency", py::overload_cast<const std::string&>(&Link::set_latency),
            py::call_guard<py::gil_scoped_release>(),
            "Set the latency as a string. Accepts values with units, such as â€˜1s’ or â€˜7ms’.\nFull list of accepted "
            "units: w (week), d (day), h, s, ms, us, ns, ps.")
-      .def("set_latency", py::overload_cast<double>(&simgrid::s4u::Link::set_latency),
-           py::call_guard<py::gil_scoped_release>(), "Set the latency as a float (in seconds).")
-      .def("set_bandwidth", &simgrid::s4u::Link::set_bandwidth, py::call_guard<py::gil_scoped_release>(),
+      .def("set_latency", py::overload_cast<double>(&Link::set_latency), py::call_guard<py::gil_scoped_release>(),
+           "Set the latency as a float (in seconds).")
+      .def("set_bandwidth", &Link::set_bandwidth, py::call_guard<py::gil_scoped_release>(),
            "Set the bandwidth (in byte per second).")
       .def(
           "set_bandwidth_profile",
-          [](simgrid::s4u::Link* l, const std::string& profile, double period) {
+          [](Link* l, const std::string& profile, double period) {
             l->set_bandwidth_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
           },
           py::call_guard<py::gil_scoped_release>(),
@@ -416,7 +436,7 @@ PYBIND11_MODULE(simgrid, m)
           "the list. Set it to -1 to not loop over.")
       .def(
           "set_latency_profile",
-          [](simgrid::s4u::Link* l, const std::string& profile, double period) {
+          [](Link* l, const std::string& profile, double period) {
             l->set_latency_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
           },
           py::call_guard<py::gil_scoped_release>(),
@@ -435,7 +455,7 @@ PYBIND11_MODULE(simgrid, m)
           "the list. Set it to -1 to not loop over.")
       .def(
           "set_state_profile",
-          [](simgrid::s4u::Link* l, const std::string& profile, double period) {
+          [](Link* l, const std::string& profile, double period) {
             l->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
           },
           "Specify a profile modeling the churn. "
@@ -450,39 +470,39 @@ PYBIND11_MODULE(simgrid, m)
           "The second function parameter is the periodicity: the time to wait after the last event to start again over "
           "the list. Set it to -1 to not loop over.")
 
-      .def("turn_on", &simgrid::s4u::Link::turn_on, py::call_guard<py::gil_scoped_release>(), "Turns the link on.")
-      .def("turn_off", &simgrid::s4u::Link::turn_off, py::call_guard<py::gil_scoped_release>(), "Turns the link off.")
-      .def("is_on", &simgrid::s4u::Link::is_on, "Check whether the link is on.")
+      .def("turn_on", &Link::turn_on, py::call_guard<py::gil_scoped_release>(), "Turns the link on.")
+      .def("turn_off", &Link::turn_off, py::call_guard<py::gil_scoped_release>(), "Turns the link off.")
+      .def("is_on", &Link::is_on, "Check whether the link is on.")
 
-      .def("set_sharing_policy", &simgrid::s4u::Link::set_sharing_policy, py::call_guard<py::gil_scoped_release>(),
+      .def("set_sharing_policy", &Link::set_sharing_policy, py::call_guard<py::gil_scoped_release>(),
            "Set sharing policy for this link")
-      .def("set_concurrency_limit", &simgrid::s4u::Link::set_concurrency_limit,
-           py::call_guard<py::gil_scoped_release>(), "Set concurrency limit for this link")
-      .def("set_host_wifi_rate", &simgrid::s4u::Link::set_host_wifi_rate, py::call_guard<py::gil_scoped_release>(),
+      .def("set_concurrency_limit", &Link::set_concurrency_limit, py::call_guard<py::gil_scoped_release>(),
+           "Set concurrency limit for this link")
+      .def("set_host_wifi_rate", &Link::set_host_wifi_rate, py::call_guard<py::gil_scoped_release>(),
            "Set level of communication speed of given host on this Wi-Fi link")
-      .def("by_name", &simgrid::s4u::Link::by_name, "Retrieves a Link from its name, or dies")
-      .def("seal", &simgrid::s4u::Link::seal, py::call_guard<py::gil_scoped_release>(), "Seal this link")
+      .def("by_name", &Link::by_name, "Retrieves a Link from its name, or dies")
+      .def("seal", &Link::seal, py::call_guard<py::gil_scoped_release>(), "Seal this link")
       .def_property_readonly(
           "name",
-          [](const simgrid::s4u::Link* self) {
+          [](const Link* self) {
             return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
           },
           "The name of this link")
-      .def_property_readonly("bandwidth", &simgrid::s4u::Link::get_bandwidth, "The bandwidth (in bytes per second)")
-      .def_property_readonly("latency", &simgrid::s4u::Link::get_latency, "The latency (in seconds)");
-
-  py::enum_<simgrid::s4u::Link::SharingPolicy>(link, "SharingPolicy")
-      .value("NONLINEAR", simgrid::s4u::Link::SharingPolicy::NONLINEAR)
-      .value("WIFI", simgrid::s4u::Link::SharingPolicy::WIFI)
-      .value("SPLITDUPLEX", simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX)
-      .value("SHARED", simgrid::s4u::Link::SharingPolicy::SHARED)
-      .value("FATPIPE", simgrid::s4u::Link::SharingPolicy::FATPIPE)
+      .def_property_readonly("bandwidth", &Link::get_bandwidth, "The bandwidth (in bytes per second)")
+      .def_property_readonly("latency", &Link::get_latency, "The latency (in seconds)");
+
+  py::enum_<Link::SharingPolicy>(link, "SharingPolicy")
+      .value("NONLINEAR", Link::SharingPolicy::NONLINEAR)
+      .value("WIFI", Link::SharingPolicy::WIFI)
+      .value("SPLITDUPLEX", Link::SharingPolicy::SPLITDUPLEX)
+      .value("SHARED", Link::SharingPolicy::SHARED)
+      .value("FATPIPE", Link::SharingPolicy::FATPIPE)
       .export_values();
 
   /* Class LinkInRoute */
   py::class_<simgrid::s4u::LinkInRoute> linkinroute(m, "LinkInRoute", "Abstraction to add link in routes");
-  linkinroute.def(py::init<const simgrid::s4u::Link*>());
-  linkinroute.def(py::init<const simgrid::s4u::Link*, simgrid::s4u::LinkInRoute::Direction>());
+  linkinroute.def(py::init<const Link*>());
+  linkinroute.def(py::init<const Link*, simgrid::s4u::LinkInRoute::Direction>());
   py::enum_<simgrid::s4u::LinkInRoute::Direction>(linkinroute, "Direction")
       .value("UP", simgrid::s4u::LinkInRoute::Direction::UP)
       .value("DOWN", simgrid::s4u::LinkInRoute::Direction::DOWN)
@@ -490,9 +510,8 @@ PYBIND11_MODULE(simgrid, m)
       .export_values();
 
   /* Class Split-Duplex Link */
-  py::class_<simgrid::s4u::SplitDuplexLink, simgrid::s4u::Link,
-             std::unique_ptr<simgrid::s4u::SplitDuplexLink, py::nodelete>>(m, "SplitDuplexLink",
-                                                                           "Network split-duplex link")
+  py::class_<simgrid::s4u::SplitDuplexLink, Link, std::unique_ptr<simgrid::s4u::SplitDuplexLink, py::nodelete>>(
+      m, "SplitDuplexLink", "Network split-duplex link")
       .def("get_link_up", &simgrid::s4u::SplitDuplexLink::get_link_up, "Get link direction up")
       .def("get_link_down", &simgrid::s4u::SplitDuplexLink::get_link_down, "Get link direction down");
 
@@ -509,6 +528,13 @@ PYBIND11_MODULE(simgrid, m)
             return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
           },
           "The name of that mailbox")
+      .def(
+          "put",
+          [](Mailbox* self, py::object data, int size, double timeout) {
+            data.inc_ref();
+            self->put(data.ptr(), size, timeout);
+          },
+          py::call_guard<py::gil_scoped_release>(), "Blocking data transmission with a timeout")
       .def(
           "put",
           [](Mailbox* self, py::object data, int size) {
@@ -627,7 +653,8 @@ PYBIND11_MODULE(simgrid, m)
               }
             });
           },
-          py::call_guard<py::gil_scoped_release>(), "Create an actor from a function or an object. See the :ref:`example <s4u_ex_actors_create>`.")
+          py::call_guard<py::gil_scoped_release>(),
+          "Create an actor from a function or an object. See the :ref:`example <s4u_ex_actors_create>`.")
       .def_property(
           "host", &Actor::get_host,
           [](Actor* a, Host* h) {
@@ -640,6 +667,8 @@ PYBIND11_MODULE(simgrid, m)
       .def_property_readonly("ppid", &Actor::get_ppid,
                              "The PID (unique identifier) of the actor that created this one.")
       .def("by_pid", &Actor::by_pid, "Retrieve an actor by its PID")
+      .def("set_auto_restart", &Actor::set_auto_restart, py::call_guard<py::gil_scoped_release>(),
+           "Specify whether the actor shall restart when its host reboots.")
       .def("daemonize", &Actor::daemonize, py::call_guard<py::gil_scoped_release>(),
            "This actor will be automatically terminated when the last non-daemon actor finishes (more info in the C++ "
            "documentation).")