Skip to content

Commit

Permalink
quick workaround to make sure serve.py doesnt read a halfway written …
Browse files Browse the repository at this point in the history
…json file
  • Loading branch information
karpathy committed Apr 15, 2020
1 parent bc717f2 commit 8ce4543
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions twitter_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ def update(i, j):
jtweets = get_tweets(j)
if jtweets is not None:
tweets[j['rel_doi']] = jtweets
write_json(tweets, 'tweets.json') # update the database
# update the database
write_json(tweets, 'tweets.tmp.json')
os.rename('tweets.tmp.json', 'tweets.json')
print('processed index %d, found %d tweets for %s' % (i, len(jtweets), j['rel_link']))
# rate limit is 180 calls per 5 minutes, or 1 call per 5 seconds. so sleep 7 for safety
time.sleep(7)
# rate limit is 180 calls per 5 minutes, or 1 call per 5 seconds. so sleep 10 for safety
time.sleep(10)

# run forever
while True:
Expand Down

0 comments on commit 8ce4543

Please sign in to comment.