celery 修改任务后,需要重启,不然不生效:
@task()
def Task_A(message):
now = datetime.datetime.now()
return message+str(now)+'scan'
node2:/celery/djtest#python manage.py celeryd -l info
/usr/local/python27/lib/python2.7/site-packages/celery/platforms.py:812: RuntimeWarning: You are running the worker with superuser privileges, which is
absolutely not recommended!
Please specify a different user using the -u option.
User information: uid=0 euid=0 gid=0 egid=0
uid=uid, euid=euid, gid=gid, egid=egid,
-------------- celery@node2 v3.1.25 (Cipater)
---- **** -----
--- * *** * -- Linux-2.6.32-431.el6.x86_64-x86_64-with-centos-6.5-Final
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: portal:0x2478490
- ** ---------- .> transport: redis://127.0.0.1:6379/0
- ** ---------- .> results: redis://127.0.0.1:6379/0
- *** --- * --- .> concurrency: 1 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. djtest.celery.debug_task
. portal.tasks.Task_A
[2017-12-05 21:15:56,820: INFO/MainProcess] Connected to redis://127.0.0.1:6379/0
[2017-12-05 21:15:56,830: INFO/MainProcess] mingle: searching for neighbors
[2017-12-05 21:15:57,837: INFO/MainProcess] mingle: all alone
[2017-12-05 21:15:57,852: WARNING/MainProcess] /usr/local/python27/lib/python2.7/site-packages/celery/fixups/django.py:265: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2017-12-05 21:15:57,852: WARNING/MainProcess] celery@node2 ready.
[2017-12-05 21:16:00,006: INFO/MainProcess] Received task: portal.tasks.Task_A[685cbe67-3efd-46db-ba53-199b9caa075a]
[2017-12-05 21:16:00,011: INFO/MainProcess] Task portal.tasks.Task_A[685cbe67-3efd-46db-ba53-199b9caa075a] succeeded in 0.00437201800014s: u'aaa2017-12-05 21:16:00.007551scan'
[2017-12-05 21:18:00,005: INFO/MainProcess] Received task: portal.tasks.Task_A[48b46f83-1fdf-4b89-bd54-1117b8a1736a]
[2017-12-05 21:18:00,008: INFO/MainProcess] Task portal.tasks.Task_A[48b46f83-1fdf-4b89-bd54-1117b8a1736a] succeeded in 0.00170183199953s: u'aaa2017-12-05 21:18:00.006713scan'