From 2e00e4aa073da6918d076cdb593248c8e01746e9 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 8 Jan 2019 06:37:28 +0100 Subject: [PATCH] python: test Actor.is_suspended() and introduce this_actor.error --- examples/python/actor-suspend/actor-suspend.py | 5 ++++- src/bindings/python/simgrid_python.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/python/actor-suspend/actor-suspend.py b/examples/python/actor-suspend/actor-suspend.py index e3036edeac..e433b7f812 100644 --- a/examples/python/actor-suspend/actor-suspend.py +++ b/examples/python/actor-suspend/actor-suspend.py @@ -32,7 +32,10 @@ def dream_master(): this_actor.info("Let's wait a little bit...") this_actor.sleep_for(10) # Wait for 10 seconds this_actor.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!") - lazy.resume() # Then wake up the lazy_guy + if lazy.is_suspended(): + lazy.resume() # Then wake up the lazy_guy + else: + this_actor.error("I was thinking that the lazy guy would be suspended now") this_actor.sleep_for(5) # Repeat two times: this_actor.info("Suspend the lazy guy while he's sleeping...") diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 1a02f46d0a..2c0c154695 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -56,6 +56,7 @@ PYBIND11_MODULE(simgrid, m) py::module m2 = m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace."); m2.def("info", [](char* s) { XBT_INFO("%s", s); }, "Display a logging message of default priority."); + m2.def("error", [](char* s) { XBT_ERROR("%s", s); }, "Display a logging message of 'error' priority."); m2.def("execute", py::overload_cast(&simgrid::s4u::this_actor::execute), "Block the current actor, computing the given amount of flops at the given priority, see :cpp:func:`void " "simgrid::s4u::this_actor::execute(double, double)`", -- 2.20.1