Skip to content

Instantly share code, notes, and snippets.

@wolfgangmeyers
Last active August 29, 2015 14:16
Show Gist options
  • Save wolfgangmeyers/c641c97e91cb4690cb25 to your computer and use it in GitHub Desktop.
Save wolfgangmeyers/c641c97e91cb4690cb25 to your computer and use it in GitHub Desktop.
Processing a really long list of things in the background using celery
@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