我将 Redis 和 Celery 一起用于 django 项目。
[前提]
django==1.5.4
Redis==2.2.4
Celery==3.0.23
django-redis==3.7.1
django-celery==3.0.23
【目录结构】
Project/
apps/
app_1/
views.py
def get_something():
utils/
redis.py
def do_stuff(): // do something related with Redis
tasks.py
@task()
def do_stuff(): // execute do_stuff() at redis.py
[问题]
在views.py中,
from utils.redis import do_stuff
from utils.tasks import do_stuff
def get_something():
do_stuff.delay() => Execute task by celery (Normal)
do_stuff() => Executed do_stuff from tasks.py, not from redis.py
Making a recursion error (Unusual)
Expected to execute do_stuff from redis.py
当函数名称重叠时,如何处理Celery仅通过“延迟方法”执行。
提前致谢。