Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/praw/models/listing/generator.py 0000-00-00 00:00:00.000000000 +0000
- +++ b/praw/models/listing/generator,py 0000-00-00 00:00:00.000000000 +0000
- @@ -49,6 +49,8 @@
- self.params["limit"] = limit or 1024
- self.url = url
- self.yielded = 0
- + self._counter2 = 0
- def __iter__(self) -> Iterator[Any]:
- """Permit :class:`.ListingGenerator` to operate as an iterator."""
- @@ -59,7 +61,7 @@
- if self.limit is not None and self.yielded >= self.limit:
- raise StopIteration()
- - if self._listing is None or self._list_index >= len(self._listing):
- + while self._listing is None or self._list_index >= len(self._listing):
- self._next_batch()
- self._list_index += 1
- @@ -84,18 +86,22 @@
- def _next_batch(self):
- if self._exhausted:
- raise StopIteration()
- self._listing = self._reddit.get(self.url, params=self.params)
- self._listing = self._extract_sublist(self._listing)
- self._list_index = 0
- - if not self._listing:
- - raise StopIteration()
- - if self._listing.after and self._listing.after != self.params.get(
- - self._listing.AFTER_PARAM
- - ):
- - self.params[self._listing.AFTER_PARAM] = self._listing.after
- + if not self._listing:
- + if self._counter2 > 5:
- + raise StopIteration()
- + self._counter2 += 1
- else:
- - self._exhausted = True
- + self._counter2 = 0
- + self.params[self._listing.AFTER_PARAM] = self._listing[-1].fullname
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement