I am looking to run queued jobs using RQ, but looking at the following example:
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
I see time.sleep(2)
- and I was wondering if this is mandatory to specify. The jobs I schedule could take (at times) an hour to complete (this varies on a per job basis).
Is RQ still suitable for such jobs - where execution time vastly varies?
Any suggestions would be great!