From 565da65ccd322be5546ed40ff54484f8e3ef7464 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 3 Jan 2015 16:13:39 +0100 Subject: Use a deque for the idle list --- slixmpp/xmlstream/asyncio.py | 6 ++++-- 1 file 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 -- cgit v1.2.3