Skip to content

Commit

Permalink
Merge pull request #17 from InesPM/master
Browse files Browse the repository at this point in the history
Fixing HTTP Error 429
  • Loading branch information
davidgardenier authored Sep 13, 2023
2 parents 988a5c5 + b36d653 commit 45a717a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frbcat/tns.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,18 @@ def row2json(self, line):
print(key, val)
return out

def get_json(self):
def get_json(self, page_length=50, sleep=0.5):
"""
Get TNS catalogue in json file format.
page_length and sleep avoid HTTP Error 429: Too Many Requests.
Args:
page_length (int): Limit of items per page that can be queried.
sleep (float): sleep time between queried pages.
"""
entries = []
more = True
page = 0
page_length = 500
page_length = 50 if page_length > 50 else page_length

if not self.mute:
m = 'Attempting to retrieve FRBs from the Transient Name Server'
Expand Down

0 comments on commit 45a717a

Please sign in to comment.