Celery cube
项目描述
CubicWeb与Celery集成
入门指南
在您的 myapp CubicWeb实例中启用‘celery’cube
$ cubicweb-ctl shell myapp entering the migration python shell just type migration commands or arbitrary python code and type ENTER to execute it type "exit" or Ctrl-D to quit the shell and resume operation >>> add_cube('celery') >>> ^D
如果需要,在 all-in-one.conf 中配置 broker_url。默认情况下,并且仅当使用postgresql数据库时,将使用 trunk 传输作为代理;请确保已安装。
编写一个任务
from cubicweb_celery import app @app.cwtask def ping(self): return 'pong' @app.cwtask def users(self): return [str(x[0]) for x in self.cw_cnx.execute('String L WHERE U login L')]
或者作为一个类
from cubicweb_celery import app class MyTask(app.Task): need_cnx = True # if false (the default), self.cw_cnx will not be set # before running the task def run(self): self.cw_cnx.execute('Any X WHERE ...')
然后启动一个celery worker
celery -A cubicweb_celery -i INSTANCE_NAME worker [ --beat ]
然后您可以通过调用它来使worker执行一个任务,例如从一个 操作。您还可以从 cubicweb-ctl shell 运行任务
$ cubicweb-ctl shell myapp >>> from cubes.myapp.sobjects import ping, users >>> print ping.delay().wait() 'pong' >>> print users.delay().wait() ['anon', 'admin']
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定要选择哪一个,请了解更多关于 安装包 的信息。
源分布
cubicweb_celery-1.1.1.tar.gz (8.1 kB 查看哈希值)
构建分布
关闭
cubicweb_celery-1.1.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cfb1c3a8d398bd15e39d76fe689e180bc558b0c4c0fef0b6ce5817101bca3001 |
|
MD5 | 28844efe074db15568c2f2334e48a3f1 |
|
BLAKE2b-256 | 0de2f8c7c977f6bda7b6e09ec5f2076e9fdab562ca1a51fd106d6ee7a1c21611 |
关闭
cubicweb_celery-1.1.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2b5b21be690ee601348c483cadad370b85d9996952cfd3038c76534890f8b4b9 |
|
MD5 | 1b6cb093f66b1a393e81ac1fee8b86c8 |
|
BLAKE2b-256 | 7476e1d9144d6d1a513d177b88a32ed2255fa1b059d1a0d9dcfc1dd23685a062 |