-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
28 lines (19 loc) · 615 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from rq import Queue
from redis import Redis
import time
from count import count_words_at_url
def send_msg_2_q():
# Tell RQ what Redis connection to use
redis_conn = Redis(host='localhost', port=6379, db=0)
q = Queue('low', connection=redis_conn)
# no args implies the default queue
# Delay execution of count_words_at_url('http://nvie.com')
job = q.enqueue(count_words_at_url, "http://nvie.com")
print(job.result) # => None
# Now, wait a while, until the worker is finished
time.sleep(2)
print(job.result) # => 889
if __name__ == "__main__":
while True:
send_msg_2_q()
time.sleep(10)