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 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 10 | |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 11 | class AggrHandler(Aggr.Iface): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 12 | def __init__(self): |
| 13 | self.values = [] |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 14 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 15 | def addValue(self, value): |
| 16 | self.values.append(value) |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 17 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 18 | def getValues(self, ): |
| 19 | time.sleep(1) |
| 20 | return self.values |
David Reiss | 5ddabb8 | 2010-10-06 17:09:37 +0000 | [diff] [blame] | 21 | |
| 22 | processor = Aggr.Processor(AggrHandler()) |
| 23 | pfactory = TBinaryProtocol.TBinaryProtocolFactory() |
| 24 | THttpServer.THttpServer(processor, ('', int(sys.argv[1])), pfactory).serve() |