- assert len(args) == 4, f"Actor master requires 4 parameters, but got {len(args)} ones."
- tasks_count = int(args[0])
- comp_size = int(args[1])
- comm_size = int(args[2])
- workers_count = int(args[3])
-
- this_actor.info(f"Got {workers_count} workers and {tasks_count} tasks to process")
-
- for i in range(tasks_count): # For each task to be executed:
- # - Select a worker in a round-robin way
- mailbox = Mailbox.by_name(f"worker-{i % workers_count}")
- try:
- this_actor.info(f"Send a message to {mailbox.name}")
- mailbox.put(comp_size, comm_size, 10.0)
- this_actor.info(f"Send to {mailbox.name} completed")
- except TimeoutException:
- this_actor.info(f"Mmh. Got timeouted while speaking to '{mailbox.name}'. Nevermind. Let's keep going!")
- except NetworkFailureException:
- this_actor.info(f"Mmh. The communication with '{mailbox.name}' failed. Nevermind. Let's keep going!")
-
- this_actor.info("All tasks have been dispatched. Let's tell everybody the computation is over.")
- for i in range (workers_count):
- # - Eventually tell all the workers to stop by sending a "finalize" task
- mailbox = Mailbox.by_name(f"worker-{i % workers_count}")
- try:
- mailbox.put(-1.0, 0, 1.0)
- except TimeoutException:
- this_actor.info(f"Mmh. Got timeouted while speaking to '{mailbox.name}'. Nevermind. Let's keep going!")
- except NetworkFailureException:
- this_actor.info(f"Mmh. The communication with '{mailbox.name}' failed. Nevermind. Let's keep going!")
-
- this_actor.info("Goodbye now!")
+ assert len(args) == 4, f"Actor master requires 4 parameters, but got {len(args)} ones."
+ tasks_count = int(args[0])
+ comp_size = int(args[1])
+ comm_size = int(args[2])
+ workers_count = int(args[3])
+
+ this_actor.info(f"Got {workers_count} workers and {tasks_count} tasks to process")
+
+ for i in range(tasks_count): # For each task to be executed:
+ # - Select a worker in a round-robin way
+ mailbox = Mailbox.by_name(f"worker-{i % workers_count}")
+ try:
+ this_actor.info(f"Send a message to {mailbox.name}")
+ mailbox.put(comp_size, comm_size, 10.0)
+ this_actor.info(f"Send to {mailbox.name} completed")
+ except TimeoutException:
+ this_actor.info(f"Mmh. Got timeouted while speaking to '{mailbox.name}'. Nevermind. Let's keep going!")
+ except NetworkFailureException:
+ this_actor.info(f"Mmh. The communication with '{mailbox.name}' failed. Nevermind. Let's keep going!")
+
+ this_actor.info("All tasks have been dispatched. Let's tell everybody the computation is over.")
+ for i in range(workers_count):
+ # - Eventually tell all the workers to stop by sending a "finalize" task
+ mailbox = Mailbox.by_name(f"worker-{i % workers_count}")
+ try:
+ mailbox.put(-1.0, 0, 1.0)
+ except TimeoutException:
+ this_actor.info(f"Mmh. Got timeouted while speaking to '{mailbox.name}'. Nevermind. Let's keep going!")
+ except NetworkFailureException:
+ this_actor.info(f"Mmh. The communication with '{mailbox.name}' failed. Nevermind. Let's keep going!")
+
+ this_actor.info("Goodbye now!")