【发布时间】:2013-12-01 18:45:24
【问题描述】:
我正在做一个“金字塔(塔)”项目。我已将 celery 配置为定期运行一些任务,并且工作正常。但我正在努力解决如何从终端手动运行任何任务。我的项目的目录结构是
/pyramid/
celeryconfig.py
development.ini
setup.py
/views/celerytasks/
__init.py__
mytask1.py
mytask2.py
这里的 'celeryconfig.py' 包含有关 celery 的所有设置,例如 'CELERY_IMPORTS'、'CELERY_QUEUES' 和 'CELERYBEAT_SCHEDULE'。我在“mytask1.py”文件中有一些任务,它曾经每天运行一次。但是我怎样才能从 pshell 手动运行它呢?我正在使用 ubuntu 10.04。
谁能告诉我?
解决方案:
1- Go to the application root folder, in my case '/pyramid/'.
2- Run 'pshell development.ini'
3- >>> from views.celerytasks.mytask1 import CeleryTask1
4- >>> celeryTask1 = CeleryTask1() // Create instance of imported class
5- >>> celeryTask1.delay() // Finally here the task will run
【问题讨论】:
-
终于找到了解决方案。只需在问题本身中查看即可。
标签: python-2.7 celery pyramid ubuntu-10.04