From 39343f414617736831237cd1d417d1ba83c8268a Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Thu, 31 Mar 2016 20:51:47 -0400 Subject: working ampoule task --- tasks.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tasks.py (limited to 'tasks.py') 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)} -- cgit v1.2.3