summaryrefslogtreecommitdiff
path: root/contrib/async-test/test-leaf.py
blob: 4ea4a9b8c0473565db246a73c33d7e13f50ca1e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
import sys
import time
from thrift.transport import TTransport
from thrift.transport import TSocket
from thrift.protocol import TBinaryProtocol
from thrift.server import THttpServer
from aggr import Aggr


class AggrHandler(Aggr.Iface):
    def __init__(self):
        self.values = []

    def addValue(self, value):
        self.values.append(value)

    def getValues(self, ):
        time.sleep(1)
        return self.values

processor = Aggr.Processor(AggrHandler())
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
THttpServer.THttpServer(processor, ('', int(sys.argv[1])), pfactory).serve()