diff options
| author | khazhyk <[email protected]> | 2019-04-07 22:56:54 -0700 |
|---|---|---|
| committer | khazhyk <[email protected]> | 2019-04-07 23:03:01 -0700 |
| commit | 7845bfb79bcff250f5c3da6a802103550e890c33 (patch) | |
| tree | 19340fa8519a978c6d517a070e7ccf004d836e3d | |
| parent | simplify AuditLogIterator ordering (diff) | |
| download | discord.py-7845bfb79bcff250f5c3da6a802103550e890c33.tar.xz discord.py-7845bfb79bcff250f5c3da6a802103550e890c33.zip | |
terminate iterators immediately once out of data
if len(data) < 100, either limit was less than 100, or we ran
out of results, in both cases, we should terminate the lookup.
This fixes, e.g., hangs in audit_logs(limit=999999), and will
reduce the number of fetch calls for any case where limit is
greater than the number of results. (Prior, would just kinda
loop calling audit-logs)
| -rw-r--r-- | discord/iterators.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/discord/iterators.py b/discord/iterators.py index 56e4d42d..8773792e 100644 --- a/discord/iterators.py +++ b/discord/iterators.py @@ -306,7 +306,7 @@ class HistoryIterator(_AsyncIterator): if self._get_retrieve(): data = await self._retrieve_messages(self.retrieve) - if self.limit is None and len(data) < 100: + if len(data) < 100: self.limit = 0 # terminate the infinite loop if self.reverse: @@ -439,7 +439,7 @@ class AuditLogIterator(_AsyncIterator): if self._get_retrieve(): users, data = await self._strategy(self.retrieve) - if self.limit is None and len(data) < 100: + if len(data) < 100: self.limit = 0 # terminate the infinite loop if self.reverse: |