summaryrefslogtreecommitdiff
path: root/tasks.py
blob: 5079e4bde4b7dc3a4cb2d3a4be2bd9bbbf51e111 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)}