Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / examples / python / actor-kill / actor-kill.py
index af47d41..43960b9 100644 (file)
@@ -1,14 +1,18 @@
-# Copyright (c) 2017-2021. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-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.
 
-from simgrid import Actor, Engine, Host, this_actor
+"""
+Usage: actor-kill.py platform_file [other parameters]
+"""
+
 import sys
+from simgrid import Actor, Engine, Host, this_actor
 
 
 def victim_a_fun():
-    this_actor.on_exit(lambda: this_actor.info("I have been killed!"))
+    this_actor.on_exit(lambda forcefully: this_actor.info("I have been killed!" if forcefully else "I finish now."))
     this_actor.info("Hello!")
     this_actor.info("Suspending myself")
     this_actor.suspend()                        # - Start by suspending itself
@@ -24,7 +28,7 @@ def victim_b_fun():
 
 
 def killer():
-    this_actor.info("Hello!")  # - First start a victim process
+    this_actor.info("Hello!")  # - First start a victim actor
     victim_a = Actor.create("victim A", Host.by_name("Fafard"), victim_a_fun)
     victim_b = Actor.create("victim B", Host.by_name("Jupiter"), victim_b_fun)
     this_actor.sleep_for(10)  # - Wait for 10 seconds
@@ -68,7 +72,7 @@ if __name__ == '__main__':
             "Usage: actor-kill.py platform_file [other parameters]")
 
     e.load_platform(sys.argv[1])     # Load the platform description
-    # Create and deploy killer process, that will create the victim actors
+    # Create and deploy killer actor, that will create the victim actors
     Actor.create("killer", Host.by_name("Tremblay"), killer)
 
     e.run()