Aggiunta codice test coda python redis con Python-RQ
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user