我对烧瓶中的芹菜有点困,
我已经准备好了这个时间表:
CELERYBEAT_SCHEDULE = {
'scandir-every-day': {
'task': 'app.core.scanAllPackages',
'schedule': crontab(hour='*/24')
},
'scandir-custo-package':{
'task': 'app.core.scanCustomPackages',
'schedule': crontab(minute='*/10')
}
}
和芹菜这样的路线:
CELERY_ROUTES={
'app.core.scanAllPackages':
{
"queue":"slow"
},
'app.core.scanCustomPackages':
{
"queue":"fast"
}
}
我在app / __ init__.py中创建了我的celery对象,如下所示:
from extensions import make_celery
celery = make_celery(app)
并且make_celery方法如下所示:
from celery import Celery
def make_celery(app):
celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
celery.Task = ContextTask
return celery
一切似乎都很好,我就像这样启动我的工人:
celery multi start fast slow -c:slow 1 -c:fast 2 -A app:celery -l debug --verbose
并且节拍如下:
celery beat -A app:celery --detach
基本上,没有任何补充,工人只是在等待,
[2015-08-12 09:45:21,182: DEBUG/MainProcess] | Worker: Starting Hub
[2015-08-12 09:45:21,182: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:21,182: DEBUG/MainProcess] | Worker: Starting Pool
[2015-08-12 09:45:21,186: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:21,187: DEBUG/MainProcess] | Worker: Starting Consumer
[2015-08-12 09:45:21,187: DEBUG/MainProcess] | Consumer: Starting Connection
[2015-08-12 09:45:21,206: INFO/MainProcess] Connected to redis://localhost:6379/0
[2015-08-12 09:45:21,206: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:21,207: DEBUG/MainProcess] | Consumer: Starting Events
[2015-08-12 09:45:21,213: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:21,213: DEBUG/MainProcess] | Consumer: Starting Mingle
[2015-08-12 09:45:21,213: INFO/MainProcess] mingle: searching for neighbors
[2015-08-12 09:45:22,218: INFO/MainProcess] mingle: all alone
[2015-08-12 09:45:22,219: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:22,219: DEBUG/MainProcess] | Consumer: Starting Gossip
[2015-08-12 09:45:22,222: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:22,222: DEBUG/MainProcess] | Consumer: Starting Tasks
[2015-08-12 09:45:22,227: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:22,227: DEBUG/MainProcess] | Consumer: Starting Control
[2015-08-12 09:45:22,229: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:22,229: DEBUG/MainProcess] | Consumer: Starting Heart
[2015-08-12 09:45:22,230: DEBUG/MainProcess] ^-- substep ok
[2015-08-12 09:45:22,230: DEBUG/MainProcess] | Consumer: Starting event loop
[2015-08-12 09:45:22,230: WARNING/MainProcess] fast@host01 ready.
[2015-08-12 09:45:22,230: DEBUG/MainProcess] | Worker: Hub.register Pool...
[2015-08-12 09:45:22,231: DEBUG/MainProcess] basic.qos: prefetch_count->8
[2015-08-12 09:45:22,932: DEBUG/MainProcess] slow@host01 joined the party
所以,如果任何人知道我的节拍有什么问题?
那会很棒,
谢谢。