-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path__init__.py
More file actions
29 lines (25 loc) · 915 Bytes
/
__init__.py
File metadata and controls
29 lines (25 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding:utf-8 -*-
from rewriting.RewritingServiceHandler import *
from rewriting import RewritingService
from rewriting.MyTBinaryProtocol import *
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.server import TServer
import threading
import sys
if __name__ == '__main__':
handler = RewritingServiceHandler()
processor = RewritingService.Processor(handler)
transport = TSocket.TServerSocket(host='127.0.0.1', port=9090)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = MyTBinaryProtocolFactory()
try:
server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory)
print 'Rewriting server:ready to start'
server.serve()
except KeyboardInterrupt:
transport.close()
sys.exit(0)
# print "Service closed successfully."
except Exception as e:
print(repr(e))