- Install rq:
pip install rq
- Run redis
docker run -p 6379:6379 redis
- Run worker
rq worker
- Run submit script
python submit.py
More info: https://python-rq.org/docs/
pip install rq
docker run -p 6379:6379 redis
rq worker
python submit.py
More info: https://python-rq.org/docs/
import requests | |
def count_words_at_url(url): | |
resp = requests.get(url) | |
return len(resp.text.split()) | |
import time | |
from redis import Redis | |
from rq import Queue | |
from my_module import count_words_at_url | |
if __name__ == '__main__': | |
q = Queue(connection=Redis()) | |
job = q.enqueue(count_words_at_url, 'http://nvie.com') | |
while job.result is None: | |
print(".", end='') | |
time.sleep(1) | |
print(job.result) |