title: TWISTED python - Wait for deferToThread to complete
body: <p>I am new to Twisted framework, and I would like to make the program wait for the deferred thread to complete.</p>
  
  <pre><code>import time
  from twisted.internet import defer, threads
  
  a=None
  def proc(n):
      time.sleep(n)
      print "Hi!!"
      a=1
      return 
  
  d = threads.deferToThread(proc,5)
  while not a:
      pass
  print a
  print "Done"
  </code></pre>
  
  <p>Is it possible to wait for the deferred to complete in a neat way rather than looping like this?</p>