我正在寻找使用 RQ 运行排队作业,但查看以下示例:
from rq import Queue
from redis import Redis
from somewhere import count_words_at_url
# Tell RQ what Redis connection to use
redis_conn = Redis()
q = Queue(connection=redis_conn) # no args implies the default queue
# Delay execution of count_words_at_url('http://nvie.com')
job = q.enqueue(count_words_at_url, 'http://nvie.com')
print job.result # => None
# Now, wait a while, until the worker is finished
time.sleep(2)
print job.result # => 889
我明白time.sleep(2)
了 - 我想知道这是否必须指定。我安排的工作可能需要(有时)一个小时才能完成(这因每个工作而异)。
RQ 是否仍然适用于执行时间差异很大的此类工作?
任何建议都会很棒!