From: Martin Quinson Date: Tue, 8 Jan 2019 22:25:58 +0000 (+0100) Subject: Missing files X-Git-Tag: v3_22~635 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2a479eb90a9ffdb7c0f7ed9829c3efd4763f5c95?ds=sidebyside Missing files --- diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index a997211d54..d9dbfc923b 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -15,5 +15,7 @@ endforeach() 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) diff --git a/examples/python/actor-lifetime/actor-lifetime.py b/examples/python/actor-lifetime/actor-lifetime.py new file mode 100644 index 0000000000..f408dc1093 --- /dev/null +++ b/examples/python/actor-lifetime/actor-lifetime.py @@ -0,0 +1,36 @@ +# 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() diff --git a/examples/python/actor-lifetime/actor-lifetime.tesh b/examples/python/actor-lifetime/actor-lifetime.tesh new file mode 100644 index 0000000000..4e52a38d6f --- /dev/null +++ b/examples/python/actor-lifetime/actor-lifetime.tesh @@ -0,0 +1,14 @@ +#!/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). + diff --git a/examples/python/actor-lifetime/actor-lifetime_d.xml b/examples/python/actor-lifetime/actor-lifetime_d.xml new file mode 100644 index 0000000000..e877e7eea3 --- /dev/null +++ b/examples/python/actor-lifetime/actor-lifetime_d.xml @@ -0,0 +1,11 @@ + + + + + + + + + + +