Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将一个项目迁移到Django并喜欢使用该django-rq模块。 但是,我被困在这里放什么:
Django
django-rq
import django_rq queue = django_rq.get_queue('high') queue.enqueue(func, foo, bar=baz)
怎么打电话func?这可以是一个字符串path.file.function吗? 该函数是否需要驻留在同一个文件中?
func
path.file.function
创建 tasks.py 文件以包含
from django_rq import job @job("high", timeout=600) # timeout is optional def your_func(): pass # do some logic
然后在你的代码中
import django_rq from tasks import your_func queue = django_rq.get_queue('high') queue.enqueue(your_func, foo, bar=baz)