Skip to content

Commit

Permalink
(Internal) Remove use of before parameter in streams
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Apr 6, 2019
1 parent c083b0b commit 7f2adcf
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions praw/models/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,37 +161,20 @@ def stream_generator(
print(comment)
"""
before_attribute = None
exponential_counter = ExponentialCounter(max_counter=16)
seen_attributes = BoundedSet(301)
without_before_counter = 0
responses_without_new = 0
valid_pause_after = pause_after is not None
while True:
found = False
newest_attribute = None
limit = 100
if before_attribute is None:
limit -= without_before_counter
without_before_counter = (without_before_counter + 1) % 30
for item in reversed(
list(
function(
limit=limit,
params={"before": before_attribute},
**function_kwargs
)
)
):
for item in reversed(list(function(limit=100, **function_kwargs))):
attribute = getattr(item, attribute_name)
if attribute in seen_attributes:
continue
found = True
seen_attributes.add(attribute)
newest_attribute = attribute
if not skip_existing:
yield item
before_attribute = newest_attribute
skip_existing = False
if valid_pause_after and pause_after < 0:
yield None
Expand Down

0 comments on commit 7f2adcf

Please sign in to comment.