Aggiunta codice test coda python redis con Python-RQ

This commit is contained in:
Samuele Locatelli
2025-04-22 17:59:48 +02:00
parent d94cf7d08b
commit 5d9d7a76e7
5 changed files with 61 additions and 0 deletions
+27
View File
@@ -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)