title: Python: Wait until certain criteria is met
body: <p>I want to make a program wait until some criteria is met. </p>
  
  <p>Is there a way that is more efficient than just looping through a while statement that has reverse criteria of what you want?</p>
  
  <p>I am writing a program with the module <code>multiprocessing</code> and using <code>Pool</code>. I need some variable that is shared between all of the processes. I am thinking of using multiprocessing's <code>Value</code> for this. The parent process will initialize this variable and pass it as an argument to <code>p.map()</code>. I want the child processes to change this variable. The intent of this is because the first part of the child processes' work should be done in parallel (computational work that doesn't need any other processes' data). But, the second part of the processes' work needs to be done in order, one process after another, because they are writing to a file and the contents of that file should be in order. My problem arises when I want the process to wait until the others are done. I will record the "progress" of the entire program with the <code>Value</code> variable, e.g. when the first process is done writing to the file, it will increment the variable by one. I want this to be a signal to the next process in line to begin writing to the file. But I need some sort of <code>waituntil()</code> function to make the processes wait until the <code>Value</code> variable indicates that it is their "turn" to write to the file.</p>