我有两个文件,完全是复制粘贴的
http://python-rq.org/docs/
:
from rq import Queue
from redis import Redis
from somewhere import count_words_at_url
import time
# Tell RQ what Redis connection to use
redis_conn = Redis()
q = Queue(connection=redis_conn) # no args implies the default queue
print(redis_conn)
# 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(10)
print(job.result) # => 889
某个地方
import requests
def count_words_at_url(url):
print("hello?")
resp = requests.get(url)
return len(resp.text.split())
app.py
,我得到的输出是2个无值,而根据文档我应该得到889。
我不太明白为什么会发生这种事。我的超时时间是10秒,比文档中的时间长,所以我希望作业已经完成。