summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-01-03 16:13:39 +0100
committerFlorent Le Coz <louiz@louiz.org>2015-01-03 16:13:39 +0100
commit565da65ccd322be5546ed40ff54484f8e3ef7464 (patch)
tree383e2d409014a11cc5ea0d97e0fcad7072eedbfa
parent47fbd4cead2e881b0250dd5f978caf64c6a5952c (diff)
downloadslixmpp-565da65ccd322be5546ed40ff54484f8e3ef7464.tar.gz
slixmpp-565da65ccd322be5546ed40ff54484f8e3ef7464.tar.bz2
slixmpp-565da65ccd322be5546ed40ff54484f8e3ef7464.tar.xz
slixmpp-565da65ccd322be5546ed40ff54484f8e3ef7464.zip
Use a deque for the idle list
-rw-r--r--slixmpp/xmlstream/asyncio.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/slixmpp/xmlstream/asyncio.py b/slixmpp/xmlstream/asyncio.py
index 52610d01..31652e4c 100644
--- a/slixmpp/xmlstream/asyncio.py
+++ b/slixmpp/xmlstream/asyncio.py
@@ -9,6 +9,8 @@ call_soon() ones. These callback are called only once each.
import asyncio
from asyncio import tasks, events
+import collections
+
def idle_call(self, callback):
if tasks.iscoroutinefunction(callback):
raise TypeError("coroutines cannot be used with idle_call()")
@@ -20,12 +22,12 @@ def my_run_once(self):
self._ready.append(events.Handle(lambda: None, (), self))
real_run_once(self)
if self._idle:
- handle = self._idle.pop(0)
+ handle = self._idle.popleft()
handle._run()
cls = asyncio.get_event_loop().__class__
-cls._idle = []
+cls._idle = collections.deque()
cls.idle_call = idle_call
real_run_once = cls._run_once
cls._run_once = my_run_once