Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Another attempt at fixing the Flag2 job of jenkins
[simgrid.git] / teshsuite / s4u / monkey-masterworkers / monkey-masterworkers.py
index e8605f9..863b392 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          
+# Copyright (c) 2007-2023. 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. 
@@ -10,7 +10,7 @@
  It is not written to be pleasant to read, but instead to resist the aggressions of the monkey:
  - Workers keep going until after a global variable `todo` reaches 0.
  - The master is a daemon that just sends infinitely tasks
-   (simgrid simulations stop as soon as all non-daemon actors are done).
+   (SimGrid simulations stop as soon as all non-daemon actors are done).
  - The platform is created programmatically to remove path issues and control the problem size.
 
  See the simgrid-monkey script for more information.
@@ -54,16 +54,16 @@ def master():
 
   assert False, "The impossible just happened (yet again): daemons shall not finish."
 
-def worker(id):
+def worker(my_id):
   global todo
-  this_actor.info(f"Worker {id} booting")
-  this_actor.on_exit(lambda killed: this_actor.info(f"Worker {id} dying {'forcefully' if killed else 'peacefully'}."))
+  this_actor.info(f"Worker {my_id} booting")
+  this_actor.on_exit(lambda killed: this_actor.info(f"Worker {my_id} dying {'forcefully' if killed else 'peacefully'}."))
 
   while todo > 0:
     assert Engine.clock < deadline, f"Failed to run all tasks in less than {deadline} seconds. Is this an infinite loop?"
 
     try:
-      this_actor.info(f"Waiting a message on mailbox")
+      this_actor.info("Waiting a message on mailbox")
       compute_cost = mailbox.get()
 
       this_actor.info("Start execution...")
@@ -78,7 +78,6 @@ def worker(id):
       this_actor.info("Timeouted while getting a task.")
 
 if __name__ == '__main__':
-  global mailbox
   e = Engine(sys.argv)
 
   assert host_count > 2, "You need at least 2 workers (i.e., 3 hosts) or the master will be auto-killed when the only worker gets killed."
@@ -93,7 +92,7 @@ if __name__ == '__main__':
   for i in range(1, host_count):
     link = rootzone.create_split_duplex_link(f"link {i}", "1MBps").set_latency("24us")
     host = rootzone.create_host(f"lilibeth {i}", 1e9)
-    rootzone.add_route(main.netpoint, host.netpoint, None, None, [LinkInRoute(link, LinkInRoute.Direction.UP)], True)
+    rootzone.add_route(main, host, [link])
     Actor.create("worker", host, worker, i).set_auto_restart(True)
 
   e.netzone_root.seal()