Skip to content

Commit

Permalink
Delay removing user from queue until much later.
Browse files Browse the repository at this point in the history
  • Loading branch information
samwightt committed Jan 16, 2019
1 parent 4100398 commit 3ec3cf9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

while True:
while redis_client.llen('userQueue') > 0:
current_user = redis_client.lpop('userQueue').decode('utf-8')
# Get first user in list non-destructively.
current_user = redis_client.lindex('userQueue', 0).decode('utf-8')
current_page = get_user_page(current_user, 1)

process_user_page(current_page)
Expand All @@ -24,5 +25,10 @@
current_page = get_user_page(current_user, i + 1)
process_user_page(current_page)
time.sleep(1)

# Finally remove the user and add to relevant queues to keep from adding again.
redis_client.lrem('userQueue', 1, current_user)
redis_client.srem('inUserQueue', current_user)
redis_client.sadd('finishedUsers', current_user)

time.sleep(1)

0 comments on commit 3ec3cf9

Please sign in to comment.