Skip to content

Instantly share code, notes, and snippets.

@pabloh007
Last active July 27, 2016 23:28
Show Gist options
  • Save pabloh007/7f55c3d2601b89bfc3ae28b872114558 to your computer and use it in GitHub Desktop.
Save pabloh007/7f55c3d2601b89bfc3ae28b872114558 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Buit-ins
import time
# PIP Installs
from celery.task import current, task
def super_long_process(c, max_count):
"""
Use the current module to set a custom state and populate with meta data
see for more info http://docs.celeryproject.org/en/latest/userguide/tasks.html#custom-states
"""
for i in xrange(1,max_count):
c.update_state(state='PROGRESS',meta={'current':i,'total':max_count})
time.sleep(4)
@celery_app.task(bind=True, ignore_result=True)
def cool_progress_task(self):
"""
execute a long running task, might no need current,
can maybe do it with self. need more investiagtion
"""
super_long_process(current, 10000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment