I have two files, literally copy-pasted from http://python-rq.org/docs/:
app.py
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
somewhere.py
import requests
def count_words_at_url(url):
print("hello?")
resp = requests.get(url)
return len(resp.text.split())
I ran app.py , and the output I got was 2 None values, as opposed to a 889 which I'm supposed to get according to the docs.
I'm not sure I understand why this is happening. My timeout is 10 seconds, and it's longer than what's in the doc, so I was expecting the job to have finished working.
What am I doing wrong?
count_words_at_url('http://nvie.com')return 889 on it's own?