Author: bryanduxbury
Date: Thu Sep  2 15:14:27 2010
New Revision: 991971

URL: http://svn.apache.org/viewvc?rev=991971&view=rev
Log:
THRIFT-597. py: Python THttpServer performance improvements

This enables buffered I/O and ThreadingMixin.

Patch: David Reiss

Modified:
    incubator/thrift/trunk/lib/py/src/server/THttpServer.py

Modified: incubator/thrift/trunk/lib/py/src/server/THttpServer.py
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/py/src/server/THttpServer.py?rev=991971&r1=991970&r2=991971&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/py/src/server/THttpServer.py (original)
+++ incubator/thrift/trunk/lib/py/src/server/THttpServer.py Thu Sep  2 15:14:27 
2010
@@ -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()


Reply via email to