def wait_for_action(self, timeout=3600, raise_on_hangup=False):
"""
Wait until an action is over
and return action event.
"""
self.log.debug("wait for action start")
try:
event = self._action_queue.get(timeout=timeout)
self.log.debug("wait for action end %s" % str(event))
if raise_on_hangup is True and self.has_hangup():
self.log.warn("wait for action call hung up !")
raise RESTHangup()
return event
except gevent.queue.Empty:
if raise_on_hangup is True and self.has_hangup():
self.log.warn("wait for action call hung up !")
raise RESTHangup()
self.log.warn("wait for action end timed out!")
return Event()
# In order to "block" the execution of our service until the
# command is finished, we use a synchronized queue from gevent
# and wait for such event to come. The on_channel_execute_complete
# method will put that event in the queue, then we may continue working.
# However, other events will still come, like for instance, DTMF.
评论列表
文章目录