1 # Copyright (c) 2019-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 # Second failing example for bug #9 on Framagit (Python bindings crashing)
8 # An intricate recursion is used to make the crash happen.
11 from simgrid import Engine, this_actor
13 def do_sleep1(i, dur):
15 this_actor.info("1-Iter {:d}".format(i))
17 this_actor.sleep_for(dur)
18 this_actor.info("1-Mid ({:d})".format(i))
19 do_sleep3(int(i / 2), dur)
20 this_actor.info("1-Done ({:d})".format(i))
22 def do_sleep3(i, dur):
24 this_actor.info("3-Iter {:d}".format(i))
26 this_actor.sleep_for(dur)
27 this_actor.info("3-Mid ({:d})".format(i))
28 do_sleep5(int(i / 2), dur)
29 this_actor.info("3-Done ({:d})".format(i))
31 def do_sleep5(i, dur):
33 this_actor.info("5-Iter {:d}".format(i))
35 this_actor.sleep_for(dur)
36 this_actor.info("5-Mid ({:d})".format(i))
37 do_sleep1(int(i / 2), dur)
38 this_actor.info("5-Done ({:d})".format(i))
49 if __name__ == '__main__':
52 e.load_platform(sys.argv[1]) # Load the platform description
54 # Register the classes representing the actors
55 e.register_actor("sleeper1", sleeper1)
56 e.register_actor("sleeper3", sleeper3)
57 e.register_actor("sleeper5", sleeper5)
59 e.load_deployment(sys.argv[2])
62 this_actor.info("Finalize!")