2016-08-25 11:52:03 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
import time
|
|
|
|
|
2016-08-31 07:54:04 +00:00
|
|
|
from celery import shared_task
|
2016-08-31 08:48:12 +00:00
|
|
|
from common import celery_app
|
2016-08-25 11:52:03 +00:00
|
|
|
|
2016-08-31 07:54:04 +00:00
|
|
|
|
|
|
|
@shared_task
|
2016-08-25 11:52:03 +00:00
|
|
|
def longtime_add(x, y):
|
|
|
|
print 'long time task begins'
|
|
|
|
# sleep 5 seconds
|
|
|
|
time.sleep(5)
|
|
|
|
print 'long time task finished'
|
2016-08-31 08:48:12 +00:00
|
|
|
return x + y
|
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(name='hello-world')
|
|
|
|
def hello():
|
|
|
|
print('hello world!')
|