1 # Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the license (GNU LGPL) which comes with this package.
6 # This Python file acts as the foil to the corresponding XML file, where the
7 # action takes place: Actors are started and stopped at predefined time
9 from simgrid import Engine, this_actor
14 """This actor just sleeps until termination"""
16 def __init__(self, *args):
17 this_actor.on_exit(lambda: this_actor.info("Exiting now (done sleeping or got killed)."))
20 this_actor.info("Hello! I go to sleep.")
21 this_actor.sleep_for(10)
22 this_actor.info("Done sleeping.")
25 if __name__ == '__main__':
29 "Usage: actor-lifetime.py platform_file actor-lifetime_d.xml [other parameters]")
31 e.load_platform(sys.argv[1]) # Load the platform description
32 e.register_actor("sleeper", Sleeper)
33 # Deploy the sleeper processes with explicit start/kill times
34 e.load_deployment(sys.argv[2])