Redis Queue implementation in Python
RQ (Redis Queue) is a simple Python library for queueing jobs and processing them in the background with workers.
RQ (Redis Queue) is a simple Python library for queueing jobs and processing them in the background with workers.
After redis installation, run the redis server with the command,
➜ redis-server
Use the below code in the mentioned files,
Get Vigneshwar Ravichandran’s stories in your inbox
Join Medium for free to get updates from this writer.
app.py
from redis import Redis
from rq import Queue
from my_module import count_words_at_urlq = Queue(connection=Redis())result = q.enqueue(count_words_at_url, 'http://nvie.com')
my_module.py
import requestsdef count_words_at_https://medium.com/url(url):
resp = requests.get(url)
return len(resp.text.split())
Pip install the below modules
➜ pip install rq
➜ pip install requests
The worker:
To start executing enqueued function calls in the background, start a worker from your project’s directory:
➜ rq worker
Run the python file app.py and check the rq worker terminal for the job updation.
For any queries ping me at https://twitter.com/vigneshwar1998







