27 lines
792 B
Python
27 lines
792 B
Python
from redis import Redis
|
|
from rq import Queue
|
|
from wcount import count_words_at_url
|
|
import time
|
|
|
|
#redis_conn = Redis()
|
|
|
|
redis_conn = Redis(
|
|
host='localhost',
|
|
port=6379,
|
|
password='24068Seriate')
|
|
|
|
q = Queue(connection=redis_conn) # no args implies the default queue
|
|
|
|
# Delay execution of count_words_at_url('http://nvie.com')
|
|
job1 = q.enqueue(count_words_at_url, 'http://nview.com')
|
|
job2 = q.enqueue(count_words_at_url, 'https://repubblica.it')
|
|
print('Job1 id: %s' % job1.id)
|
|
print('Job2 id: %s' % job2.id)
|
|
|
|
print(job1.result) # => None # Changed to job.return_value() in RQ >= 1.12.0
|
|
print(job2.result) # => None # Changed to job.return_value() in RQ >= 1.12.0
|
|
|
|
# Now, wait a while, until the worker is finished
|
|
time.sleep(2)
|
|
print(job1.result)
|
|
print(job2.result) |