mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-597. py: Python THttpServer performance improvements
This enables buffered I/O and ThreadingMixin. Patch: David Reiss git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991971 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2ef59ffbf
commit
d6a02ff99b
@ -29,7 +29,8 @@ class THttpServer(TServer.TServer):
|
||||
acting as a mock version of an Apache-based PHP Thrift endpoint."""
|
||||
|
||||
def __init__(self, processor, server_address,
|
||||
inputProtocolFactory, outputProtocolFactory = None):
|
||||
inputProtocolFactory, outputProtocolFactory = None,
|
||||
server_class = BaseHTTPServer.HTTPServer):
|
||||
"""Set up protocol factories and HTTP server.
|
||||
|
||||
See BaseHTTPServer for server_address.
|
||||
@ -52,12 +53,14 @@ class THttpServer(TServer.TServer):
|
||||
|
||||
itrans = TTransport.TFileObjectTransport(self.rfile)
|
||||
otrans = TTransport.TFileObjectTransport(self.wfile)
|
||||
itrans = TTransport.TBufferedTransport(itrans, int(self.headers['Content-Length']))
|
||||
otrans = TTransport.TBufferedTransport(otrans)
|
||||
iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
|
||||
oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
|
||||
thttpserver.processor.process(iprot, oprot)
|
||||
otrans.flush()
|
||||
|
||||
self.httpd = BaseHTTPServer.HTTPServer(server_address, RequestHander)
|
||||
self.httpd = server_class(server_address, RequestHander)
|
||||
|
||||
def serve(self):
|
||||
self.httpd.serve_forever()
|
||||
|
Loading…
Reference in New Issue
Block a user