title: Alternative to Busy-Wait Structure Python
body: <p>In a program I am writing, I have a small problem.  I would like to be able to know when an element has been created but do not have access to the element's library.  The library provides a function that returns True or False when it is finished and ready to continue. Currently I am using a busy wait structure such as:</p>
  
  <pre><code>    def Waiting_Procedure():
          finished = false
          while not finished:
              time.sleep(1)
              if library_function_returns_true:
                  finished = true
  </code></pre>
  
  <p>This works fine for now, but I'd like to know if there is a better/simpler/elegant way to accomplish this in Python.  Also, if the library never returns true, it would spin forever at 1 second intervals, which would not be ideal.</p>
  
  <p>Thanks!</p>