Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / examples / python / actor-create / actor-create.py
index 3bd71d5..4b04a06 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2006-2022. 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.
@@ -16,8 +16,8 @@
 # application and the settings to test it. This is a better scientific methodology. Actually, starting an actor with
 # Actor.create() is mostly useful to start an actor from another actor.
 
+from simgrid import Actor, Engine, Host, Mailbox, this_actor
 import sys
-from simgrid import *
 
 
 def receiver(mailbox_name):
@@ -59,10 +59,12 @@ class Sender:
     Later, this actor class is instantiated twice in the simulation.
     """
 
-    def __init__(self, msg = "GaBuZoMeu", mbox = "mb42"):
+    def __init__(self, msg="GaBuZoMeu", mbox="mb42"):
         self.msg = msg
         self.mbox = mbox
 
+    # Actors that are created as object will execute their __call__ method.
+    # So, the following constitutes the main function of the Sender actor.
     def __call__(self):
         this_actor.info("Hello s4u, I have something to send")
         mailbox = Mailbox.by_name(self.mbox)
@@ -72,7 +74,7 @@ class Sender:
 
 
 if __name__ == '__main__':
-    """Here comes the main function of your program"""
+    # Here comes the main function of your program
 
     # When your program starts, you have to first start a new simulation engine, as follows
     e = Engine(sys.argv)