[Zope-Checkins] CVS: Zope/lib/python/ZServer -
FTPResponse.py:1.13.44.1 FTPServer.py:1.26.8.3.6.1
Chris McDonough
chrism at plope.com
Sun Mar 28 04:38:51 EST 2004
Update of /cvs-repository/Zope/lib/python/ZServer
In directory cvs.zope.org:/tmp/cvs-serv18110
Modified Files:
Tag: chrism-publishfile-branch
FTPResponse.py FTPServer.py
Log Message:
Handle return of stream iterator in ftp server.
Speed up FTP downloads by about 100X.
=== Zope/lib/python/ZServer/FTPResponse.py 1.13 => 1.13.44.1 ===
--- Zope/lib/python/ZServer/FTPResponse.py:1.13 Tue Mar 18 16:15:14 2003
+++ Zope/lib/python/ZServer/FTPResponse.py Sun Mar 28 04:38:50 2004
@@ -26,9 +26,6 @@
"""
def __str__(self):
-# return ZServerHTTPResponse.__str__(self)
- # ZServerHTTPResponse.__str__(self) return HTTP headers
- # Why should be send them to the FTP client ??? (ajung)
return ''
def outputBody(self):
=== Zope/lib/python/ZServer/FTPServer.py 1.26.8.3 => 1.26.8.3.6.1 ===
--- Zope/lib/python/ZServer/FTPServer.py:1.26.8.3 Wed Dec 17 16:00:43 2003
+++ Zope/lib/python/ZServer/FTPServer.py Sun Mar 28 04:38:50 2004
@@ -308,7 +308,19 @@
if status==200:
self.make_xmit_channel()
if not response._wrote:
- self.client_dc.push(response.body)
+ # chrism: we explicitly use a large-buffered producer here to
+ # increase speed. Using "client_dc.push" with the body causes
+ # a simple producer with a buffer size of 512 to be created
+ # to serve the data, and it's very slow
+ # (about 100 times slower than the large-buffered producer)
+ self.client_dc.push_with_producer(
+ asynchat.simple_producer(response.body, 1<<16))
+ # chrism: if the response has a bodyproducer, it means that
+ # the actual body was likely an empty string. This happens
+ # typically when someone returns a StreamIterator from
+ # Zope application code.
+ if response._bodyproducer:
+ self.client_dc.push_with_producer(response._bodyproducer)
else:
for producer in self._response_producers:
self.client_dc.push_with_producer(producer)
@@ -645,3 +657,4 @@
# override asyncore limits for nt's listen queue size
self.accepting = 1
return self.socket.listen (num)
+
More information about the Zope-Checkins
mailing list