File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 11from collections import namedtuple
2-
2+ import time
33from .rpc import PiazzaRPC
44
55
@@ -82,7 +82,7 @@ def get_post(self, cid):
8282 """
8383 return self ._rpc .content_get (cid = cid )
8484
85- def iter_all_posts (self , limit = None ):
85+ def iter_all_posts (self , limit = None , sleep = 0 ):
8686 """Get all posts visible to the current user
8787
8888 This grabs you current feed and ids of all posts from it; each post
@@ -91,6 +91,8 @@ def iter_all_posts(self, limit=None):
9191 caution to the user when using this.
9292
9393 :type limit: int|None
94+ sleep:int -- If given, will allow to actually iterate through all of
95+ Piazza channel's posts without getting kicked or banned by Piazza.
9496 :param limit: If given, will limit the number of posts to fetch
9597 before the generator is exhausted and raises StopIteration.
9698 No special consideration is given to `0`; provide `None` to
@@ -102,6 +104,7 @@ def iter_all_posts(self, limit=None):
102104 feed = self .get_feed (limit = 999999 , offset = 0 )
103105 cids = [post ['id' ] for post in feed ["feed" ]]
104106 if limit is not None :
107+ time .sleep (sleep )
105108 cids = cids [:limit ]
106109 for cid in cids :
107110 yield self .get_post (cid )
You can’t perform that action at this time.
0 commit comments