foriinrange(1,size):# End all workers by sending an empty task
comm.send({"workstr":""},i)
#### Go into working loop
WLPosition=0
SenderFSM=0#0=Preparing for receive, 1=waiting between jobs, 2=waiting for rank to ask for taks, 5=Send empty taks to all
WorkerFSM=0#0=Send a request to Master, 1=wait for sending to comnplete, prepare for answer, 2=waiting for answer, start processing, 3=running, 4=completed and reset
SenderLastJobTimeStamp=0# to allow for delays between launched jobs
whileTrue:
####
# Distribution stuff
if(rank==0):
ifSenderFSM==0:
if(WLPosition<len(worklist)):# still some work to be distributed
r2=comm.irecv(tag=2)# wait for a worker to connect and get the rank of the free worker
logger.info("Waiting for some worker to connect...")
SenderFSM=1
else:#no more work in the list
SenderFSM=5
foriinrange(0,size):# End all workers by sending an empty task
logger.info("Sending an empty task to rank "+str(i)+"...")