Yield new items from ListingGenerators and None when paused.

Parameters: function – A callable that returns a ListingGenerator, e.g. subreddit.comments or subreddit.new .

– A callable that returns a ListingGenerator, e.g. or . pause_after – An integer representing the number of requests that result in no new items before this function yields None , effectively introducing a pause into the stream. A negative value yields None after items from a single response have been yielded, regardless of number of new items obtained in that response. A value of 0 yields None after every response resulting in no new items, and a value of None never introduces a pause (default: None).

– An integer representing the number of requests that result in no new items before this function yields , effectively introducing a pause into the stream. A negative value yields after items from a single response have been yielded, regardless of number of new items obtained in that response. A value of yields after every response resulting in no new items, and a value of never introduces a pause (default: None). skip_existing – When True does not yield any results from the first request thereby skipping any items that existed in the stream prior to starting the stream (default: False).

– When True does not yield any results from the first request thereby skipping any items that existed in the stream prior to starting the stream (default: False). attribute_name – The field to use as an id (default: “fullname”).

– The field to use as an id (default: “fullname”). exclude_before – When True does not pass params to functions (default: False).

Additional keyword arguments will be passed to function .

Note This function internally uses an exponential delay with jitter between subsequent responses that contain no new results, up to a maximum delay of just over a 16 seconds. In practice that means that the time before pause for pause_after=N+1 is approximately twice the time before pause for pause_after=N .

For example, to create a stream of comment replies, try:

reply_function = reddit . inbox . comment_replies for reply in praw . models . util . stream_generator ( reply_function ): print ( reply )

To pause a comment stream after six responses with no new comments, try:

subreddit = reddit . subreddit ( "redditdev" ) for comment in subreddit . stream . comments ( pause_after = 6 ): if comment is None : break print ( comment )

To resume fetching comments after a pause, try:

subreddit = reddit . subreddit ( "help" ) comment_stream = subreddit . stream . comments ( pause_after = 5 ) for comment in comment_stream : if comment is None : break print ( comment ) # Do any other processing, then try to fetch more data for comment in comment_stream : if comment is None : break print ( comment )

To bypass the internal exponential backoff, try the following. This approach is useful if you are monitoring a subreddit with infrequent activity, and you want the to consistently learn about new items from the stream as soon as possible, rather than up to a delay of just over sixteen seconds.