我正在尝试使用AsyncResult访问不同助手函数中芹菜任务的taskid,但无法访问它
https://celery.readthedocs.io/en/latest/reference/celery.result.html#celery.result.AsyncResult
我在这个链接上一无所获,还尝试了其他一些链接,比如https://docs.celeryproject.org/en/latest/userguide/tasks.html
def anotherFunction(data):
try:
fvlfn
except Exception as identifier:
logging.exception(identifier)
@app.task(bind=True)
def send(self):
try:
TASKID = self.request.id
anotherFunction('no if s')
except Exception as identifier:
self.update_state(state='ALMOST DONE')
logging.exception(self.request.id)
我想在另一个函数中访问taskid而不传递它
始终可以使用芹菜应用程序对象来获取有关当前任务的信息:
myapp.current_task.request.id
(其中myapp是芹菜类的实例)然而,仅仅因为你可以,并不意味着这就是你应该做的。我们中的许多人喜欢显式地传递函数运行所需的数据,而不是使用一些全局对象
相关问题 更多 >
编程相关推荐