David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import sys |
| 3 | import time |
| 4 | from thrift.transport import TTransport |
| 5 | from thrift.transport import TSocket |
| 6 | from thrift.protocol import TBinaryProtocol |
| 7 | from thrift.server import THttpServer |
| 8 | from aggr import Aggr |
| 9 | |
| 10 | class AggrHandler(Aggr.Iface): |
| 11 | def __init__(self): |
| 12 | self.values = [] |
| 13 | |
| 14 | def addValue(self, value): |
| 15 | self.values.append(value) |
| 16 | |
| 17 | def getValues(self, ): |
| 18 | time.sleep(1) |
| 19 | return self.values |
| 20 | |
| 21 | processor = Aggr.Processor(AggrHandler()) |
| 22 | pfactory = TBinaryProtocol.TBinaryProtocolFactory() |
| 23 | THttpServer.THttpServer(processor, ('', int(sys.argv[1])), pfactory).serve() |