python - celery python对象方法

标签 python celery

我正在尝试围绕 python 对象方法获取 celery 任务包装器。喜欢:

 class A:
      @task
      def test_task(self,args):
        print "BLah..test"

   def main():
     a= A()
     args = {}
     a.test_task(args)

现在失败并出现错误 test_task 需要至少 2 个参数(给定 1 个)。 我的理解是 self 对象没有通过。为什么会这样?我该如何解决这个问题?

更新: 这真的是我对 celery 缺乏了解。 @task 装饰器只是添加/处理与 celery 任务相关的参数。它不会自动使对函数的每次调用都成为 celery 任务。该函数必须被称为 a.test_task.delay(args).. 其中的问题...

最佳答案

从 3.0 版本开始,Celery 现在支持使用方法作为任务: http://docs.celeryproject.org/en/latest/reference/celery.contrib.methods.html

关于python - celery python对象方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8846489/

相关文章:

python - 有条件的多个条件

python - GetElementIds() 获取当前选择的问题

python - Celery pickle type content disallowed 错误

python - 如何获取Celery中的所有任务和周期性任务

python - 重复轮询列表以查看哪个作业已完成的最佳方法

python - 确保 Celery 中不同来源的任务顺序

python - 调用 celery 任务挂起延迟和 apply_async

python - Web2py + MS SQL Server 2008 R2 + LDAP 身份验证 HelloWorld 应用程序?

python - pandas - 根据另一列更改列中的值

python - Tkinter 最大化/恢复/调整差异化大小