我是python的新手,但我知道自我会自动通过。我无法理解为什么我会收到此错误,并且我得到了与getGraph函数相同的错误以及2所需的1。 这里出了什么问题?
CreateDoc位于CeleryTasks.py和insert_manager的MongoTriggers.py
@app.task
def createDoc(self):
print ("CeleryTasks:CreateDoc")
if 'refs' not in self.data:
return
print(self.data['refs'])
for id in self.data['refs']:
doc = self.db[self.collName].find_one({'_id': id})
if doc is None:
insertedID = self.db[self.collName].insert_one({
"_id": id
})
print (insertedID)
#Trigger on Mongo Operations
def insert_manager(op_document):
print("Data Inserted")
# pprint.pprint (op_document)
data = op_document['o']
ns = op_document['ns'].split('.')
# pprint.pprint (data)
docID = op_document['o']['_id']
tasks = CeleryTasks(port, docID, dbName, collectionName, data)
tasks.createDoc()
tasks.getGraph.delay(docID)
答案 0 :(得分:0)
self
总是在它的类方法时传递。
芹菜任务是独立的功能。您可以通过self
装饰器添加bind=True
来添加app
参数,但它们用于其他目的:bounded tasks