Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
[bugfix] Paginator should stop iteration when completed
Browse files Browse the repository at this point in the history
  • Loading branch information
b1naryth1ef committed Aug 11, 2017
1 parent 13f70e7 commit 3496d6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## v0.0.12

### Fixes

- Fixed `Paginator` throwing an exception when reaching the end of pagination, instead of just ending its iteration

## v0.0.11

### Additions
Expand Down
6 changes: 4 additions & 2 deletions disco/util/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def fill(self):
result = self.func(*self.args, **self.kwargs)

if not len(result):
return
return 0

self._buffer.extend(result)
self._sort_key_value = self._key(result[-1])
return len(result)

def next(self):
return self.__next__()
Expand All @@ -34,7 +35,8 @@ def __iter__(self):

def __next__(self):
if not len(self._buffer):
self.fill()
if not self.fill():
raise StopIteration

if self._bulk:
res = self._buffer
Expand Down

0 comments on commit 3496d6f

Please sign in to comment.