title: Python script for showing an asterisk while waiting 10 seconds
body: <p>I'm trying to place a call 'on hold' in asterisk using a python AGI script, the function will check if the person is available, when he is asterisk will dial the person if he is not the script should wait 10 seconds before checking availabilty again and dial when the person is available. However I ran into a small problem, using the <code>time.sleep(10)</code> function hangs up the call when a person is not available, I expect this is because the thread the script runs on will sleep and asterisk thinks the script is done running and hangs up the call. Removing the <code>time.sleep()</code> gives me what I want without the time interval.</p>
  
  <pre><code>agi = AGI()
  agi.verbose("python agi started")
  place_call_on_hold("SIP/6001")
  
  def place_call_on_hold(s):
    agi.verbose("entered place_call_on_hold function")
    while True:
      status = agi.get_variable('DEVICE_STATE(%(redirect)s)'%{'redirect':s})
      agi.verbose(status)
      if status == 'NOT_INUSE':
        agi.verbose("Info: place_call_on_hold: calling the number")
        agi.appexec("Dial",s)
      else:
        agi.verbose("Info: place_call_on_hold: sleeping for 10 sec")
        time.sleep(10)
  </code></pre>
  
  <p>Is there a way to wait 10 seconds without using the <code>sleep()</code> function or how can I make sure the call won't end before the <code>time.sleep</code> wakes back up?</p>