import time from mpi4py import MPI import threading def plan_delivery(message, recipient, tag, time=1): thread = threading.Thread(target=deliver, args=(message, recipient, tag, time,)) thread.start() def deliver(message, recipient, tag, sleep=1): time.sleep(sleep) conn.isend(message, recipient, tag) conn = MPI.COMM_WORLD rank = conn.Get_rank() print(f"Is root : {rank == 0}") size = conn.Get_size() print(f"COMM_WORLD size is {size}") if rank == 0: plan_delivery("Houston, we have a Problem!", rank, 1) message = conn.irecv(source=0, tag=1) message = message.wait() print(f"Message received: {message}") # Bcast kann direkt in Variablen einschreiben text = "Groundcontrol to Major Tom" response = conn.bcast(text, 0) print(f"Response received: {response}") if rank == 0: X = list(range(1, 5)) else: X = None # Gather schreibt in ein array, hier mit allen bei den clients registrierten X gathered_data = conn.gather(X, root=0) print(gathered_data)