Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / teshsuite / python / borken-context / borken-context.py
1 # Copyright (c) 2019-2021. The SimGrid Team. All rights reserved.
2 #
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.
5
6 # First failing example for bug #9 on Framagit (Python bindings crashing)
7 #
8 # A heavy operation is added after e.run() (here, it's "import gc"). Note that
9 # the failure only occurs when the actor "sender" starts first, and the
10 # scheduling is interlaced: sender starts, receiver starts, sender terminates,
11 # receiver terminates.
12
13 import sys
14 from simgrid import Engine, this_actor
15
16 def sender():
17     this_actor.sleep_for(3)
18     this_actor.info("Goodbye now!")
19
20 def receiver():
21     this_actor.sleep_for(5)
22     this_actor.info("Five seconds elapsed")
23
24 if __name__ == '__main__':
25     e = Engine(sys.argv)
26
27     e.load_platform(sys.argv[1])             # Load the platform description
28
29     # Register the classes representing the actors
30     e.register_actor("sender", sender)
31     e.register_actor("receiver", receiver)
32
33     e.load_deployment(sys.argv[2])
34
35     e.run()
36     this_actor.info("Dummy import...")
37     import gc
38     gc.collect()
39     this_actor.info("done.")