diff options
Diffstat (limited to 'tasks.py')
-rw-r--r-- | tasks.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..5079e4b --- /dev/null +++ b/tasks.py @@ -0,0 +1,21 @@ +from twisted.protocols import amp +from ampoule import child + + +def fib(n): + if n <= 2: + return 1 + else: + return fib(n-1) + fib(n-2) + + +class Fib(amp.Command): + response = [("fib", amp.Integer())] + + +class FibCalculator(child.AMPChild): + @Fib.responder + def fib(self): + print 'called responder, fib...' + n = 10 + return {"fib": fib(n)} |