summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBryan Duxbury <bryanduxbury@apache.org>2010-09-02 15:14:27 +0000
committerBryan Duxbury <bryanduxbury@apache.org>2010-09-02 15:14:27 +0000
commitd6a02ff99bcee734d5335c91f5ada41d7322ecb4 (patch)
treeda4d50582679554e45b64ed0a50e2cffad2da1d6 /lib
parentf2ef59ffbf7819d7e89e73ba78c5900778cbe293 (diff)
downloadthrift-d6a02ff99bcee734d5335c91f5ada41d7322ecb4.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/py/src/server/THttpServer.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/py/src/server/THttpServer.py b/lib/py/src/server/THttpServer.py
index 21fc31418..9bf80cbb8 100644
--- a/lib/py/src/server/THttpServer.py
+++ b/lib/py/src/server/THttpServer.py
@@ -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()