Add Client.purge_from as a high level interface around bulk delete.

This commit is contained in:
Rapptz
2016-05-10 08:38:12 -04:00
parent 1b601097d2
commit 1f86a9b795
2 changed files with 84 additions and 5 deletions

View File

@ -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...