aboutsummaryrefslogtreecommitdiff
path: root/discord/iterators.py
diff options
context:
space:
mode:
Diffstat (limited to 'discord/iterators.py')
-rw-r--r--discord/iterators.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/discord/iterators.py b/discord/iterators.py
index 6a1d8952..f74227d8 100644
--- a/discord/iterators.py
+++ b/discord/iterators.py
@@ -52,6 +52,13 @@ class LogsFromIterator:
for element in data:
yield from self.messages.put(Message(channel=self.channel, **element))
+ @asyncio.coroutine
+ def iterate(self):
+ if self.messages.empty():
+ yield from self.fill_messages()
+
+ return self.messages.get_nowait()
+
if PY35:
@asyncio.coroutine
def __aiter__(self):
@@ -59,11 +66,8 @@ class LogsFromIterator:
@asyncio.coroutine
def __anext__(self):
- if self.messages.empty():
- yield from self.fill_messages()
-
try:
- msg = self.messages.get_nowait()
+ msg = yield from self.iterate()
return msg
except asyncio.QueueEmpty:
# if we're still empty at this point...