mirror of https://github.com/rq/rq.git
Adapt examples so they run again.
Remove sync part of the example.
This commit is contained in:
parent
56fc74118e
commit
cd31f6aba9
|
@ -1,21 +1,15 @@
|
|||
import os
|
||||
import time
|
||||
from rq import push_connection
|
||||
from rq import conn
|
||||
from redis import Redis
|
||||
from fib import slow_fib
|
||||
|
||||
push_connection(Redis())
|
||||
# Tell rq what Redis connection to use
|
||||
conn.push(Redis())
|
||||
|
||||
sync = False
|
||||
if sync:
|
||||
print 'Synchronously:'
|
||||
for x in range(22, 33):
|
||||
print 'fib(%d) = %d' % (x, slow_fib(x))
|
||||
print 'Done'
|
||||
else:
|
||||
# Kick off the tasks asynchronously
|
||||
async_results = {}
|
||||
for x in range(22, 33):
|
||||
for x in range(20, 30):
|
||||
async_results[x] = slow_fib.delay(x)
|
||||
|
||||
done = False
|
||||
|
@ -23,7 +17,7 @@ else:
|
|||
os.system('clear')
|
||||
print 'Asynchronously: (now = %s)' % time.time()
|
||||
done = True
|
||||
for x in range(22, 33):
|
||||
for x in range(20, 30):
|
||||
result = async_results[x].return_value
|
||||
if result is None:
|
||||
done = False
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
from redis import Redis
|
||||
from rq import push_connection
|
||||
from rq import conn
|
||||
from rq.daemon import run_daemon
|
||||
|
||||
push_connection(Redis())
|
||||
# Tell rq what Redis connection to use
|
||||
conn.push(Redis())
|
||||
|
||||
run_daemon(['default'])
|
||||
listen_on_queues = ['default']
|
||||
run_daemon(listen_on_queues)
|
||||
|
|
Loading…
Reference in New Issue