File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -143,17 +143,24 @@ def get_subscription_list(self):
143143 for item in response ['subscriptions' ]:
144144 yield Subscription .from_json (item )
145145
146- def get_stream_contents (self , stream_id , c = '' ):
147- while True :
146+ def get_stream_contents (self , stream_id , c = '' , limit = None ):
147+ fetched_count = 0
148+ stop = False
149+ while not stop :
148150 articles , c = self .__get_stream_contents (stream_id , c )
149151 for a in articles :
150152 try :
151153 yield Article .from_json (a )
154+ fetched_count += 1
152155 except Exception as e :
153156 print (e )
154157 continue
158+ if limit and fetched_count >= limit :
159+ stop = True
160+ break
155161 if c is None :
156162 break
163+
157164
158165 def __get_stream_contents (self , stream_id , continuation = '' ):
159166 self .check_token ()
You can’t perform that action at this time.
0 commit comments