]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/tutorial/py.twisted/PythonServer.tac
4 # Licensed to the Apache Software Foundation (ASF) under one
5 # or more contributor license agreements. See the NOTICE file
6 # distributed with this work for additional information
7 # regarding copyright ownership. The ASF licenses this file
8 # to you under the Apache License, Version 2.0 (the
9 # "License"); you may not use this file except in compliance
10 # with the License. You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing,
15 # software distributed under the License is distributed on an
16 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 # KIND, either express or implied. See the License for the
18 # specific language governing permissions and limitations
22 from twisted
.application
import internet
, service
23 from thrift
.transport
import TTwisted
27 sys
.path
.append('gen-py.twisted')
28 sys
.path
.insert(0, glob
.glob('../../lib/py/build/lib*')[0])
29 from tutorial
import Calculator
30 from PythonServer
import CalculatorHandler
31 from thrift
.protocol
import TBinaryProtocol
34 def make_application():
35 application
= service
.Application('CalcServer')
37 handler
= CalculatorHandler()
38 processor
= Calculator
.Processor(handler
)
40 serverFactory
= TTwisted
.ThriftServerFactory(
42 TBinaryProtocol
.TBinaryProtocolFactory())
44 calcService
= internet
.TCPServer(9090, serverFactory
)
46 multiService
= service
.MultiService()
47 calcService
.setServiceParent(multiService
)
48 multiService
.setServiceParent(application
)
52 if __name__
== '__main__':
53 application
= make_application()