【发布时间】:2011-05-31 21:13:15
【问题描述】:
从 celery.decorators 导入任务
from celery.decorators import task
@task()
def add(x, y):
r = open("./abc.txt","w")
r.write("sdf")
r.close()
return x + y
这是我的 tasks.py 文件。
>>> import tasks
>>> r = tasks.add.delay(3,5)
>>> r.result
8
如您所见,该功能有效。但是,文件不会创建。 为什么?
由于可能存在权限问题,我已尝试更改多个文件路径。但没有运气。
【问题讨论】:
-
你怎么知道它不起作用?如果你使用绝对路径而不是相对路径呢?
标签: python django file rabbitmq celery