我的RQ任务运行正常,但没有一个功能可以完成所有的工作。--
$ pip3 freeze | egrep -i "rq|redis"
redis==2.10.6
rq==0.12.0
$ flask shell
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
App: app [production]
Instance: .../flask/instance
>>> from redis import Redis
>>> import rq
>>> q = rq.Queue('example-rq', connection=Redis.from_url('redis://'))
>>> job = q.enqueue('app.tasks.example', 100)
>>> job.get_id()
'93c0e279-3ce7-48c6-8f97-ace8a29ada70'
>>> q.job_ids
[]
>>> q.get_job_ids()
[]
>>> q.jobs
[]
示例任务非常基本--
$ cat app/tasks.py
from time import sleep
from rq import get_current_job
# duration in second
def example(duration):
job = get_current_job()
print("Starting task example " + job.get_id())
for i in range(duration):
job.meta['progress'] = 100.0 * i / duration
job.save_meta()
if i%5 == 0:
print(i)
sleep(1)
job.meta['progress'] = 100
job.save_meta()
print("Completed task example")
可能出了什么问题?顺便说一句,这是Ubuntu 18.04的内容