From 63ef198fd6fedb8d19168f8f2f0aa686e7196112 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Fri, 10 Feb 2012 18:32:59 +0100 Subject: [PATCH] Improve work generator. --- bin/rqgenload | 9 +++++---- rq/dummy.py | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/rqgenload b/bin/rqgenload index 674889c..7eb6f49 100755 --- a/bin/rqgenload +++ b/bin/rqgenload @@ -18,10 +18,7 @@ def main(): use_redis() - #funcs = filter(lambda s: not s.startswith('_'), dir(rq.dummy)) - #print(funcs) - - queues = ('default', 'high', 'normal', 'low') + queues = ('default', 'high', 'low') sample_calls = [ (dummy.do_nothing, [], {}), @@ -30,6 +27,10 @@ def main(): (dummy.do_nothing, [], {}), (dummy.do_nothing, [], {}), (dummy.sleep, [1], {}), + (dummy.fib, [8], {}), # normal result + (dummy.fib, [24], {}), # takes pretty long + (dummy.div_by_zero, [], {}), # 5 / 0 => div by zero exc + (dummy.fib, [30], {}), # takes long, then crashes ] for i in range(opts.count): diff --git a/rq/dummy.py b/rq/dummy.py index f4b8dc2..b2ad055 100644 --- a/rq/dummy.py +++ b/rq/dummy.py @@ -21,6 +21,12 @@ def endless_loop(): def div_by_zero(): 1/0 +def fib(n): + if n <= 1: + return 1 + else: + return fib(n-2) + fib(n-1) + def yield_stuff(): yield 7 yield 'foo'