Celery
基于Python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处理。
使用场景:
1.如果现在有一个非常复杂的批量命令,一台机器计算会花费很长时间,并且每台机器会花比较长的事件,可以借助多台机器来执行,但是又不想让程序等待下去,而是返回一个任务id,之后拿着这个任务id就可以拿到任务执行结果。
2.如果想做一个定时任务,现在有一个文件需要每天的早上7点30分执行,此时就可以用到
在执行任务时候,需要通过消息中间件来接收或者发送任务消息,以及存储任务结果,可以使用rabbitmq和redis
Celery的特点
- 简单:一单熟悉了celery的工作流程后,配置和使用还是比较简单的
- 高可用:当任务执行失败或执行过程中发生连接中断,celery 会自动尝试重新执行任务
- 快速:一个单进程的celery每分钟可处理上百万个任务
- 灵活: 几乎celery的各个组件都可以被扩展及自定制
Celery的基本工作原理图
使用Celery
安装Celery
1 pip3 install celery
s1.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 import time 5 from celery import Celery 6 7 8 app = Celery( 9 'tasks', 10 broker='redis://:mchotdog@192.168.1.6:6379', 11 # 存结果 12 backend='redis://:mchotdog@192.168.1.6:6379' 13 ) 14 15 16 @app.task 17 def add(x, y): 18 """ 19 一个worker处理执行任务 20 :param x: 21 :param y: 22 :return: 23 """ 24 return x + y 25 26 27 @app.task 28 def mul(x, y): 29 time.sleep(20) 30 return x * y 31 32 33 @app.task 34 def xsub(x, y): 35 time.sleep(10) 36 return x - y
s2.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 from s1 import add, mul, xsub 4 5 t1 = add.delay(4, 5) 6 print(t1.get()) # 得到任务id 7 print(t1) 8 9 10 t2 = mul.delay(4, 5) # 延迟执行 11 print(t2.ready()) # 是否执行完 12 print(t2) 13 14 15 t3 = xsub.delay(5, 4) 16 print(t3)
开启worker,执行任务
1 # 任务 2 celery worker -A s1 -l info -P eventlet 3 4 -------------- celery@DESKTOP-VGDG9UJ v4.3.0 (rhubarb) 5 ---- **** ----- 6 --- * *** * -- Windows-10-10.0.17134-SP0 2019-10-23 09:11:45 7 -- * - **** --- 8 - ** ---------- [config] # 信息 9 - ** ---------- .> app: tasks:0x294709a2438 10 - ** ---------- .> transport: redis://:**@192.168.1.6:6379// 11 - ** ---------- .> results: redis://:**@192.168.1.6:6379/ 12 - *** --- * --- .> concurrency: 4 (eventlet) 13 -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) 14 --- ***** ----- 15 -------------- [queues] 16 .> celery exchange=celery(direct) key=celery 17 18 19 [tasks] 20 . s1.add 21 . s1.mul 22 . s1.xsub 23 24 [2019-10-23 09:11:45,521: INFO/MainProcess] Connected to redis://:**@192.168.1.6:6379// 25 [2019-10-23 09:11:45,540: INFO/MainProcess] mingle: searching for neighbors 26 [2019-10-23 09:11:46,582: INFO/MainProcess] mingle: all alone 27 [2019-10-23 09:11:46,608: INFO/MainProcess] pidbox: Connected to redis://:**@192.168.1.6:6379//. 28 [2019-10-23 09:11:46,615: INFO/MainProcess] celery@DESKTOP-VGDG9UJ ready. 29 [2019-10-23 09:11:58,383: INFO/MainProcess] Received task: s1.add[7a31f4b1-6974-49e6-b929-1aa2cd57f72d] 30 [2019-10-23 09:11:58,389: INFO/MainProcess] Received task: s1.mul[4b4647c6-300b-41c8-8a56-ac9e980fe070] 31 [2019-10-23 09:11:58,393: INFO/MainProcess] Task s1.add[7a31f4b1-6974-49e6-b929-1aa2cd57f72d] succeeded in 0.0s: 9 32 [2019-10-23 09:11:58,397: INFO/MainProcess] Received task: s1.xsub[fd293916-0c48-4293-ba3f-a1294f248bae] 33 [2019-10-23 09:12:03,411: INFO/MainProcess] Task s1.xsub[fd293916-0c48-4293-ba3f-a1294f248bae] succeeded in 5.015999999945052s: 1 34 [2019-10-23 09:12:08,382: INFO/MainProcess] Task s1.mul[4b4647c6-300b-41c8-8a56-ac9e980fe070] succeeded in 10.0s: 20 35 36 worker: Hitting Ctrl+C again will terminate all running tasks! 37 38 worker: Warm shutdown (MainProcess) 39 40 41 42 celery worker -A s1 -l info -P eventlet 43 44 -------------- celery@DESKTOP-VGDG9UJ v4.3.0 (rhubarb) 45 ---- **** ----- 46 --- * *** * -- Windows-10-10.0.17134-SP0 2019-10-23 09:15:59 47 -- * - **** --- 48 - ** ---------- [config] 49 - ** ---------- .> app: tasks:0x24a19582438 50 - ** ---------- .> transport: redis://:**@192.168.1.6:6379// 51 - ** ---------- .> results: redis://:**@192.168.1.6:6379/ 52 - *** --- * --- .> concurrency: 4 (eventlet) 53 -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) 54 --- ***** ----- 55 -------------- [queues] 56 .> celery exchange=celery(direct) key=celery 57 58 59 [tasks] 60 . s1.add 61 . s1.mul 62 . s1.xsub 63 64 [2019-10-23 09:15:59,190: INFO/MainProcess] Connected to redis://:**@192.168.1.6:6379// 65 [2019-10-23 09:15:59,211: INFO/MainProcess] mingle: searching for neighbors 66 [2019-10-23 09:16:00,271: INFO/MainProcess] mingle: all alone 67 [2019-10-23 09:16:00,301: INFO/MainProcess] celery@DESKTOP-VGDG9UJ ready. 68 [2019-10-23 09:16:00,325: INFO/MainProcess] pidbox: Connected to redis://:**@19 69 2.168.1.6:6379//. 70 [2019-10-23 09:16:05,618: INFO/MainProcess] Received task: s1.add[9bac291f-26da 71 -4e76-ada5-b704bc9b9d22] 72 [2019-10-23 09:16:05,623: INFO/MainProcess] Task s1.add[9bac291f-26da-4e76-ada5 73 -b704bc9b9d22] succeeded in 0.0s: 9 74 [2019-10-23 09:16:05,630: INFO/MainProcess] Received task: s1.mul[dbcd1a3c-8716 75 -4ac0-886e-c5b2c29dd1a1] 76 [2019-10-23 09:16:05,637: INFO/MainProcess] Received task: s1.xsub[334eeff3-d9cd-4fe0-8da1-144d2e0c17db] 77 [2019-10-23 09:16:15,640: INFO/MainProcess] Task s1.xsub[334eeff3-d9cd-4fe0-8da1-144d2e0c17db] succeeded in 10.0s: 1 78 [2019-10-23 09:16:25,638: INFO/MainProcess] Task s1.mul[dbcd1a3c-8716-4ac0-886e-c5b2c29dd1a1] succeeded in 20.0s: 20
在项目中使用
1.创文件夹projcelery
2.创__init__.py文件
3.创celery.py文件 实例celery
4.tasks.py 任务
5.tasks2.py 任务
6.s3.py 执行
7.periodic_tasks.py 定时任务
celery.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 from __future__ import absolute_import, unicode_literals 5 from celery import Celery 6 7 8 app = Celery('proj', 9 broker='redis://:mchotdog@192.168.1.6:6379', 10 backend='redis://:mchotdog@192.168.1.6:6379', 11 # 可以执行多个任务 任务列表 12 include=['projcelery.tasks', 'projcelery.tasks2', 'projcelery.periodic_tasks'] 13 ) 14 15 16 app.conf.update( 17 # 所有任务周期保存一个小时 18 result_expires=3600, 19 ) 20 21 22 if __name__ == '__main__': 23 app.start()
tasks.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 from __future__ import absolute_import, unicode_literals 5 from .celery import app 6 7 8 @app.task 9 def add(x, y): 10 """ 11 一个worker处理执行任务 12 :param x: 13 :param y: 14 :return: 15 """ 16 return x + y 17 18 19 @app.task 20 def mul(x, y): 21 return x * y 22 23 24 @app.task 25 def xsub(x, y): 26 return x - y
tasks2.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 from __future__ import absolute_import, unicode_literals 5 from .celery import app 6 7 8 @app.task 9 def cmd(cmd): 10 print('running cmd...%s' % cmd) 11 12 13 @app.task 14 def file_transfer(filename): 15 print('sending file%s' % filename)
s3.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 from projcelery import tasks, tasks2 5 6 t1 = tasks.add.delay(4, 5) 7 # apply_async从现在起多久内执行 8 # https://docs.celeryproject.org/en/latest/userguide/calling.html 9 print(t1.get()) 10 11 t2 = tasks2.cmd.delay('df') 12 t2.get()
periodic_tasks.py
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 from __future__ import absolute_import, unicode_literals 5 from celery.schedules import crontab 6 from .celery import app 7 8 9 @app.on_after_configure.connect 10 def setup_periodic_tasks(sender, **kwargs): 11 # Calls test('hello') every 10 seconds. 12 sender.add_periodic_task(10.0, test.s('hello'), name='add every 10') 13 14 # Calls test('world') every 30 seconds 15 sender.add_periodic_task(30.0, test.s('world'), expires=10) 16 17 # Executes every Monday morning at 7:30 a.m. 18 sender.add_periodic_task( 19 crontab(hour=7, minute=30, day_of_week=1), 20 test.s('Happy Mondays!'), 21 ) 22 23 24 @app.task 25 def test(arg): 26 print('run func', arg) 27 28 29 """ 30 直接配置 31 app.conf.beat_schedule = { 32 'add-every-30-seconds': { 33 'task': 'projcelery.tasks.add', 34 'schedule': 30.0, 35 'args': (16, 16) 36 }, 37 'add-every-5-seconds': { 38 'task': 'projcelery.tasks.mul', 39 'schedule': 30.0, 40 'args': (16, 16) 41 }, 42 'add-every-monday-morning': { 43 'task': 'projcelery.tasks.add', 44 'schedule': crontab(hour=7, minute=30, day_of_week=1), 45 'args': (16, 16), 46 }, 47 } 48 app.conf.timezone = 'UTC' 49 50 官方更多:https://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html 51 """
执行任务启动worker
1 celery worker -A projcelery -l info -P eventlet 2 3 -------------- celery@DESKTOP-VGDG9UJ v4.3.0 (rhubarb) 4 ---- **** ----- 5 --- * *** * -- Windows-10-10.0.17134-SP0 2019-10-23 09:46:34 6 -- * - **** --- 7 - ** ---------- [config] 8 - ** ---------- .> app: proj:0x13f4a1437f0 9 - ** ---------- .> transport: redis://:**@192.168.1.6:6379// 10 - ** ---------- .> results: redis://:**@192.168.1.6:6379/ 11 - *** --- * --- .> concurrency: 4 (eventlet) 12 -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) 13 14 --- ***** ----- 15 -------------- [queues] 16 .> celery exchange=celery(direct) key=celery 17 18 19 [tasks] 20 . projcelery.tasks.add 21 . projcelery.tasks.mul 22 . projcelery.tasks.xsub 23 . projcelery.tasks2.cmd 24 . projcelery.tasks2.file_transfer 25 26 [2019-10-23 09:46:34,132: INFO/MainProcess] Connected to redis://:**@192.168.1.6:6379// 27 [2019-10-23 09:46:34,146: INFO/MainProcess] mingle: searching for neighbors 28 [2019-10-23 09:46:35,193: INFO/MainProcess] mingle: all alone 29 [2019-10-23 09:46:35,239: INFO/MainProcess] pidbox: Connected to redis://:**@192.168.1.6:6379//. 30 [2019-10-23 09:46:35,250: INFO/MainProcess] celery@DESKTOP-VGDG9UJ ready. 31 [2019-10-23 09:53:11,130: INFO/MainProcess] Received task: projcelery.tasks.add[eaa65597-c72d-4f81-9cc1-bb0be710044c] 32 [2019-10-23 09:53:11,137: INFO/MainProcess] Task projcelery.tasks.add[eaa65597-c72d-4f81-9cc1-bb0be710044c] succeeded in 0.0s: 9 33 [2019-10-23 09:53:11,147: INFO/MainProcess] Received task: projcelery.tasks2.cmd[5a9cfe36-45ac-4967-9ed8-e70438ada059] 34 [2019-10-23 09:53:11,149: WARNING/MainProcess] running cmd...df 35 [2019-10-23 09:53:11,153: INFO/MainProcess] Task projcelery.tasks2.cmd[5a9cfe36-45ac-4967-9ed8-e70438ada059] succeeded in 0.0s: None 36 37 38 39 # 定时任务 40 41 celery worker -A projcelery -l info -P eventlet 42 43 -------------- celery@DESKTOP-VGDG9UJ v4.3.0 (rhubarb) 44 ---- **** ----- 45 --- * *** * -- Windows-10-10.0.17134-SP0 2019-10-23 10:24:50 46 -- * - **** --- 47 - ** ---------- [config] 48 - ** ---------- .> app: proj:0x20984012898 49 - ** ---------- .> transport: redis://:**@192.168.1.6:6379// 50 - ** ---------- .> results: redis://:**@192.168.1.6:6379/ 51 - *** --- * --- .> concurrency: 4 (eventlet) 52 -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) 53 54 --- ***** ----- 55 -------------- [queues] 56 .> celery exchange=celery(direct) key=celery 57 58 59 [tasks] 60 . projcelery.periodic_tasks.test 61 . projcelery.tasks.add 62 . projcelery.tasks.mul 63 . projcelery.tasks.xsub 64 . projcelery.tasks2.cmd 65 . projcelery.tasks2.file_transfer 66 67 [2019-10-23 10:24:50,344: INFO/MainProcess] Connected to redis://:**@192.168.1. 68 6:6379// 69 [2019-10-23 10:24:50,366: INFO/MainProcess] mingle: searching for neighbors 70 [2019-10-23 10:24:51,416: INFO/MainProcess] mingle: all alone 71 [2019-10-23 10:24:51,445: INFO/MainProcess] celery@DESKTOP-VGDG9UJ ready. 72 [2019-10-23 10:24:51,460: INFO/MainProcess] pidbox: Connected to redis://:**@192.168.1.6:6379//. 73 [2019-10-23 10:29:50,609: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[9f716f60-ad33-433b-976b-7dda736d9b69] 74 [2019-10-23 10:29:50,611: WARNING/MainProcess] run func 75 [2019-10-23 10:29:50,611: WARNING/MainProcess] hello 76 [2019-10-23 10:29:50,614: INFO/MainProcess] Task projcelery.periodic_tasks.test[9f716f60-ad33-433b-976b-7dda736d9b69] succeeded in 0.01600000006146729s: None 77 [2019-10-23 10:30:00,568: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[1a89b72b-c94a-4586-a423-220b98e2f5a8] 78 [2019-10-23 10:30:00,571: WARNING/MainProcess] run func 79 [2019-10-23 10:30:00,571: WARNING/MainProcess] hello 80 [2019-10-23 10:30:00,575: INFO/MainProcess] Task projcelery.periodic_tasks.test[1a89b72b-c94a-4586-a423-220b98e2f5a8] succeeded in 0.0s: None 81 [2019-10-23 10:30:10,565: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[31677b5f-34f2-4949-9771-07b064fca9d6] expires:[2019-10-23 02:30:20.5617 82 13+00:00] 83 [2019-10-23 10:30:10,567: WARNING/MainProcess] run func 84 [2019-10-23 10:30:10,570: WARNING/MainProcess] world 85 [2019-10-23 10:30:10,572: INFO/MainProcess] Task projcelery.periodic_tasks.test[31677b5f-34f2-4949-9771-07b064fca9d6] succeeded in 0.0s: None 86 [2019-10-23 10:30:10,575: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[ce1764a0-82ee-4a3f-b8be-4d826e2a702a] 87 [2019-10-23 10:30:10,577: WARNING/MainProcess] run func 88 [2019-10-23 10:30:10,577: WARNING/MainProcess] hello 89 [2019-10-23 10:30:10,579: INFO/MainProcess] Task projcelery.periodic_tasks.test[ce1764a0-82ee-4a3f-b8be-4d826e2a702a] succeeded in 0.0s: None 90 [2019-10-23 10:30:20,572: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[ebb12862-cc95-47bf-a30c-da5d0be56293] 91 [2019-10-23 10:30:20,574: WARNING/MainProcess] run func 92 [2019-10-23 10:30:20,575: WARNING/MainProcess] hello 93 [2019-10-23 10:30:20,577: INFO/MainProcess] Task projcelery.periodic_tasks.test[ebb12862-cc95-47bf-a30c-da5d0be56293] succeeded in 0.0s: None 94 [2019-10-23 10:30:30,571: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[9da5dce4-d998-4a66-bb31-749b861232e5] 95 [2019-10-23 10:30:30,572: WARNING/MainProcess] run func 96 [2019-10-23 10:30:30,573: WARNING/MainProcess] hello 97 [2019-10-23 10:30:30,574: INFO/MainProcess] Task projcelery.periodic_tasks.test[9da5dce4-d998-4a66-bb31-749b861232e5] succeeded in 0.0s: None 98 [2019-10-23 10:30:40,568: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[f7562d85-fd95-43c3-89e4-58d9e4e24645] expires:[2019-10-23 02:30:50.5641 99 49+00:00] 100 [2019-10-23 10:30:40,569: WARNING/MainProcess] run func 101 [2019-10-23 10:30:40,569: WARNING/MainProcess] world 102 [2019-10-23 10:30:40,572: INFO/MainProcess] Task projcelery.periodic_tasks.test[f7562d85-fd95-43c3-89e4-58d9e4e24645] succeeded in 0.0s: None 103 [2019-10-23 10:30:40,573: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[29c9b910-fea5-49f8-9957-2dee80db275e] 104 [2019-10-23 10:30:40,574: WARNING/MainProcess] run func 105 [2019-10-23 10:30:40,576: WARNING/MainProcess] hello 106 [2019-10-23 10:30:40,578: INFO/MainProcess] Task projcelery.periodic_tasks.test[29c9b910-fea5-49f8-9957-2dee80db275e] succeeded in 0.0s: None 107 [2019-10-23 10:30:50,569: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[01dd9c2c-8d00-42b8-b9f8-7688ce3bf07e] 108 [2019-10-23 10:30:50,571: WARNING/MainProcess] run func 109 [2019-10-23 10:30:50,571: WARNING/MainProcess] hello 110 [2019-10-23 10:30:50,573: INFO/MainProcess] Task projcelery.periodic_tasks.test[01dd9c2c-8d00-42b8-b9f8-7688ce3bf07e] succeeded in 0.0s: None 111 [2019-10-23 10:31:00,571: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[7317825d-e396-47c1-a1b6-8d8f760f8886] 112 [2019-10-23 10:31:00,572: WARNING/MainProcess] run func 113 [2019-10-23 10:31:00,572: WARNING/MainProcess] hello 114 [2019-10-23 10:31:00,574: INFO/MainProcess] Task projcelery.periodic_tasks.test[7317825d-e396-47c1-a1b6-8d8f760f8886] succeeded in 0.0s: None 115 [2019-10-23 10:31:10,566: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[a2c0ccf9-47c8-457e-a0b6-6a0fb4021240] expires:[2019-10-23 02:31:20.5625 116 61+00:00] 117 [2019-10-23 10:31:10,567: WARNING/MainProcess] run func 118 [2019-10-23 10:31:10,567: WARNING/MainProcess] world 119 [2019-10-23 10:31:10,570: INFO/MainProcess] Task projcelery.periodic_tasks.test[a2c0ccf9-47c8-457e-a0b6-6a0fb4021240] succeeded in 0.0s: None 120 [2019-10-23 10:31:10,572: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[4254c779-7050-424c-8ebd-de4ac20e8712] 121 [2019-10-23 10:31:10,574: WARNING/MainProcess] run func 122 [2019-10-23 10:31:10,574: WARNING/MainProcess] hello 123 [2019-10-23 10:31:10,578: INFO/MainProcess] Task projcelery.periodic_tasks.test[4254c779-7050-424c-8ebd-de4ac20e8712] succeeded in 0.0s: None 124 [2019-10-23 10:31:20,574: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[127b1fac-2a79-4df8-83b5-9fb725887606] 125 [2019-10-23 10:31:20,576: WARNING/MainProcess] run func 126 [2019-10-23 10:31:20,576: WARNING/MainProcess] hello 127 [2019-10-23 10:31:20,578: INFO/MainProcess] Task projcelery.periodic_tasks.test[127b1fac-2a79-4df8-83b5-9fb725887606] succeeded in 0.0s: None 128 [2019-10-23 10:31:30,574: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[0c5a3f3c-9144-4f44-9479-cfce5634eb61] 129 [2019-10-23 10:31:30,575: WARNING/MainProcess] run func 130 [2019-10-23 10:31:30,575: WARNING/MainProcess] hello 131 [2019-10-23 10:31:30,577: INFO/MainProcess] Task projcelery.periodic_tasks.test[0c5a3f3c-9144-4f44-9479-cfce5634eb61] succeeded in 0.0s: None 132 [2019-10-23 10:31:40,580: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[89e78fd0-d274-443a-8879-c4697852f3c2] expires:[2019-10-23 02:31:50.5640 133 49+00:00] 134 [2019-10-23 10:31:40,582: WARNING/MainProcess] run func 135 [2019-10-23 10:31:40,583: WARNING/MainProcess] world 136 [2019-10-23 10:31:40,592: INFO/MainProcess] Task projcelery.periodic_tasks.test[89e78fd0-d274-443a-8879-c4697852f3c2] succeeded in 0.015999999945051968s: None 137 [2019-10-23 10:31:40,611: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[3795df0f-5a99-4fb8-be3c-0859922c33da] 138 [2019-10-23 10:31:40,612: WARNING/MainProcess] run func 139 [2019-10-23 10:31:40,630: WARNING/MainProcess] hello 140 [2019-10-23 10:31:40,641: INFO/MainProcess] Task projcelery.periodic_tasks.test[3795df0f-5a99-4fb8-be3c-0859922c33da] succeeded in 0.03200000000651926s: None 141 [2019-10-23 10:31:50,584: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[e44cfba4-4144-49f4-b9ea-f5fe1e2d5153] 142 [2019-10-23 10:31:50,585: WARNING/MainProcess] run func 143 [2019-10-23 10:31:50,585: WARNING/MainProcess] hello 144 [2019-10-23 10:31:50,586: INFO/MainProcess] Task projcelery.periodic_tasks.test[e44cfba4-4144-49f4-b9ea-f5fe1e2d5153] succeeded in 0.0s: None 145 [2019-10-23 10:32:00,585: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[f44e70bd-2082-4b48-9f1a-d137052aae06] 146 [2019-10-23 10:32:00,586: WARNING/MainProcess] run func 147 [2019-10-23 10:32:00,587: WARNING/MainProcess] hello 148 [2019-10-23 10:32:00,589: INFO/MainProcess] Task projcelery.periodic_tasks.test[f44e70bd-2082-4b48-9f1a-d137052aae06] succeeded in 0.0s: None 149 [2019-10-23 10:32:10,571: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[92c22682-dbc2-44be-85ab-9a1b064046ed] expires:[2019-10-23 02:32:20.5676 150 02+00:00] 151 [2019-10-23 10:32:10,572: WARNING/MainProcess] run func 152 [2019-10-23 10:32:10,573: WARNING/MainProcess] world 153 [2019-10-23 10:32:10,574: INFO/MainProcess] Task projcelery.periodic_tasks.test[92c22682-dbc2-44be-85ab-9a1b064046ed] succeeded in 0.0s: None 154 [2019-10-23 10:32:10,584: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[4c283bb5-a2da-42e8-924b-1d011891e8e7] 155 [2019-10-23 10:32:10,586: WARNING/MainProcess] run func 156 [2019-10-23 10:32:10,586: WARNING/MainProcess] hello 157 [2019-10-23 10:32:10,588: INFO/MainProcess] Task projcelery.periodic_tasks.test[4c283bb5-a2da-42e8-924b-1d011891e8e7] succeeded in 0.0s: None 158 [2019-10-23 10:32:20,586: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[825a19ca-d111-4815-b793-ee280474b8ec] 159 [2019-10-23 10:32:20,588: WARNING/MainProcess] run func 160 [2019-10-23 10:32:20,589: WARNING/MainProcess] hello 161 [2019-10-23 10:32:20,592: INFO/MainProcess] Task projcelery.periodic_tasks.test[825a19ca-d111-4815-b793-ee280474b8ec] succeeded in 0.0s: None 162 [2019-10-23 10:32:30,583: INFO/MainProcess] Received task: projcelery.periodic_tasks.test[bc4de97b-2ef9-4f5a-aa3b-799f22210423] 163 [2019-10-23 10:32:30,584: WARNING/MainProcess] run func 164 [2019-10-23 10:32:30,585: WARNING/MainProcess] hello 165 [2019-10-23 10:32:30,587: INFO/MainProcess] Task projcelery.periodic_tasks.test[bc4de97b-2ef9-4f5a-aa3b-799f22210423] succeeded in 0.0s: None 166 167 168 169 170 celery beat -A projcelery.periodic_tasks -l info 171 celery beat v4.3.0 (rhubarb) is starting. 172 __ - ... __ - _ 173 LocalTime -> 2019-10-23 10:29:40 174 Configuration -> 175 . broker -> redis://:**@192.168.1.6:6379// 176 . loader -> celery.loaders.app.AppLoader 177 . scheduler -> celery.beat.PersistentScheduler 178 . db -> celerybeat-schedule 179 . logfile -> [stderr]@%INFO 180 . maxinterval -> 5.00 minutes (300s) 181 [2019-10-23 10:29:40,528: INFO/MainProcess] beat: Starting... 182 [2019-10-23 10:29:50,580: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 183 [2019-10-23 10:30:00,561: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 184 [2019-10-23 10:30:10,561: INFO/MainProcess] Scheduler: Sending due task projcelery.periodic_tasks.test('world') (projcelery.periodic_tasks.test) 185 [2019-10-23 10:30:10,564: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 186 [2019-10-23 10:30:20,565: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 187 [2019-10-23 10:30:30,566: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 188 [2019-10-23 10:30:40,562: INFO/MainProcess] Scheduler: Sending due task projcelery.periodic_tasks.test('world') (projcelery.periodic_tasks.test) 189 [2019-10-23 10:30:40,566: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 190 [2019-10-23 10:30:50,566: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 191 [2019-10-23 10:31:00,567: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 192 [2019-10-23 10:31:10,562: INFO/MainProcess] Scheduler: Sending due task projcelery.periodic_tasks.test('world') (projcelery.periodic_tasks.test) 193 [2019-10-23 10:31:10,568: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 194 [2019-10-23 10:31:20,569: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 195 [2019-10-23 10:31:30,570: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 196 [2019-10-23 10:31:40,563: INFO/MainProcess] Scheduler: Sending due task projcelery.periodic_tasks.test('world') (projcelery.periodic_tasks.test) 197 [2019-10-23 10:31:40,578: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 198 [2019-10-23 10:31:50,578: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 199 [2019-10-23 10:32:00,578: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 200 [2019-10-23 10:32:10,563: INFO/MainProcess] Scheduler: Sending due task projcelery.periodic_tasks.test('world') (projcelery.periodic_tasks.test) 201 [2019-10-23 10:32:10,578: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 202 [2019-10-23 10:32:20,579: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test) 203 [2019-10-23 10:32:30,579: INFO/MainProcess] Scheduler: Sending due task add every 10 (projcelery.periodic_tasks.test)
基于RabbitMQ接收发送任务更新中..........................