Logo AND Algorithmique Numérique Distribuée

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