Switched DTMF batch implementation to use deque
This commit is contained in:
parent
e501754aab
commit
dcc6869a0f
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue