当我尝试用芹菜运行任务时,Pymongo集合对象失败。我想它不能序列化。我该怎么办?顺便说一句,我试过泡菜,但没用。在
PS:我不想把全局数据库导入这个模块。在
“Collection”对象不可调用。如果你的意思是调用new方法。。。。在
示例代码如下。 模块.py
from celery.contrib.methods import task_method
class Some_Class(object):
"""docstring for Some_Class"""
def __init__(self, db):
super(Some_Class, self).__init__()
self.db = db # This object causes 'Collection' object is not callable
#db is a pymongo collection object from db.py
@app.task(filter=task_method) # Celery task
def add(self):
"""
db.insert({'some_key':'some_value'})
"""
return 3
数据库
^{pr2}$
你在Windows机器上运行这个代码吗?由于Windows上不存在fork,因此可能存在底层fork问题,因此对象可能无法拾取,从而导致错误。在
相关问题 更多 >
编程相关推荐