Switched DTMF batch implementation to use deque

This commit is contained in:
Alexander Cherniuk 2010-03-23 11:45:58 +02:00
parent e501754aab
commit dcc6869a0f
1 changed files with 5 additions and 3 deletions

View File

@ -15,6 +15,8 @@
Handles Jingle RTP sessions (XEP 0167)
"""
from collections import deque
import gobject
import socket
@ -122,15 +124,15 @@ class JingleRTPContent(JingleContent):
"""
if self._dtmf_running:
raise Exception("There is a DTMF batch already running")
events = list(events)
events = deque(events)
self._dtmf_running = True
self._start_dtmf(events.pop(0))
self._start_dtmf(events.popleft())
gobject.timeout_add(500, self._next_dtmf, events)
def _next_dtmf(self, events):
self._stop_dtmf()
if events:
self._start_dtmf(events.pop(0))
self._start_dtmf(events.popleft())
gobject.timeout_add(500, self._next_dtmf, events)
else:
self._dtmf_running = False