Skip to content

Commit

Permalink
Update network.py (#62)
Browse files Browse the repository at this point in the history
* Update network.py

I put the time.sleep in the wrong place.

* Update network.py
  • Loading branch information
j-beastman authored Jul 27, 2023
1 parent 63db1ed commit e6b03b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion piazza_api/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def iter_all_posts(self, limit=None, sleep=0):
:type limit: int|None
sleep:int -- If given, will allow to actually iterate through all of
Piazza channel's posts without getting kicked or banned by Piazza.
Around 1 second works in practice if you're iterating through
a lot of posts.
:param limit: If given, will limit the number of posts to fetch
before the generator is exhausted and raises StopIteration.
No special consideration is given to `0`; provide `None` to
Expand All @@ -104,9 +106,9 @@ def iter_all_posts(self, limit=None, sleep=0):
feed = self.get_feed(limit=999999, offset=0)
cids = [post['id'] for post in feed["feed"]]
if limit is not None:
time.sleep(sleep)
cids = cids[:limit]
for cid in cids:
time.sleep(sleep)
yield self.get_post(cid)

def create_post(self, post_type, post_folders, post_subject, post_content, is_announcement=0, bypass_email=0, anonymous=False):
Expand Down

0 comments on commit e6b03b8

Please sign in to comment.