Last active
August 29, 2015 14:16
-
-
Save wolfgangmeyers/c641c97e91cb4690cb25 to your computer and use it in GitHub Desktop.
Processing a really long list of things in the background using celery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@celery.task | |
def process_list_of_things(things): | |
try: | |
for i in range(min(20, len(things))): | |
thing = things.pop() | |
process_thing(thing) | |
except SoftTimeLimitExceeded: | |
things.append(thing) | |
if things: | |
process_list_of_things.delay(things) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment