set(tesh_files examples/python/actor-create/actor-create_d.xml
examples/python/actor-lifetime/actor-lifetime_d.xml
+ examples/python/actor-lifetime/actor-lifetime.py # example broken so far
+ examples/python/actor-lifetime/actor-lifetime.tesh
${tesh_files} PARENT_SCOPE)
set(examples_src ${examples_src} PARENT_SCOPE)
--- /dev/null
+# Copyright (c) 2007-2019. 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.
+
+# This Python file acts as the foil to the corresponding XML file, where the
+# action takes place: Actors are started and stopped at predefined time
+
+from simgrid import *
+import sys
+
+
+class Sleeper:
+ """This actor just sleeps until termination"""
+
+ def __init__(self, *args):
+ this_actor.on_exit(lambda: print("BAAA")) # sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed)."))
+
+ def __call__(self):
+ this_actor.info("Hello! I go to sleep.")
+ this_actor.sleep_for(10)
+ this_actor.info("Done sleeping.")
+
+
+if __name__ == '__main__':
+ e = Engine(sys.argv)
+ if len(sys.argv) < 2:
+ raise AssertionError(
+ "Usage: actor-lifetime.py platform_file actor-lifetime_d.xml [other parameters]")
+
+ e.load_platform(sys.argv[1]) # Load the platform description
+ e.register_actor("sleeper", Sleeper)
+ # Deploy the sleeper processes with explicit start/kill times
+ e.load_deployment(sys.argv[2])
+
+ e.run()
--- /dev/null
+#!/usr/bin/env tesh
+
+$ python3 ${bindir:=.}/actor-lifetime.py ${platfdir}/cluster_backbone.xml actor-lifetime_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:sleeper@node-0.simgrid.org) Hello! I go to sleep.
+> [ 0.000000] (2:sleeper@node-1.simgrid.org) Hello! I go to sleep.
+> [ 2.000000] (3:sleeper@node-0.simgrid.org) Hello! I go to sleep.
+> [ 3.000000] (2:sleeper@node-1.simgrid.org) Exiting now (done sleeping or got killed).
+> [ 4.000000] (4:sleeper@node-2.simgrid.org) Hello! I go to sleep.
+> [ 7.000000] (4:sleeper@node-2.simgrid.org) Exiting now (done sleeping or got killed).
+> [ 10.000000] (1:sleeper@node-0.simgrid.org) Done sleeping.
+> [ 10.000000] (1:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed).
+> [ 12.000000] (3:sleeper@node-0.simgrid.org) Done sleeping.
+> [ 12.000000] (3:sleeper@node-0.simgrid.org) Exiting now (done sleeping or got killed).
+
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+
+<!-- This shows how to use the start_time and kill_time attributes of <actors> -->
+
+<platform version="4.1">
+ <actor host="node-0.simgrid.org" function="sleeper" />
+ <actor host="node-0.simgrid.org" function="sleeper" start_time="2" />
+ <actor host="node-1.simgrid.org" function="sleeper" kill_time="3" />
+ <actor host="node-2.simgrid.org" function="sleeper" start_time="4" kill_time="7" />
+</platform>