[Zope-Checkins]
SVN: Zope/branches/ajung-fast-listen-branch/lib/python/Z
applied patches for 'fast_listen' directive..some more work to do:
Andreas Jung
andreas at andreas-jung.com
Tue Aug 29 08:04:50 EDT 2006
Log message for revision 69833:
applied patches for 'fast_listen' directive..some more work to do:
- wording
- hard-coded listen(1024) call
- tests?
Changed:
U Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/HTTPServer.py
U Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/component.xml
U Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/datatypes.py
U Zope/branches/ajung-fast-listen-branch/lib/python/Zope2/Startup/__init__.py
-=-
Modified: Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/HTTPServer.py
===================================================================
--- Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/HTTPServer.py 2006-08-29 09:34:43 UTC (rev 69832)
+++ Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/HTTPServer.py 2006-08-29 12:04:49 UTC (rev 69833)
@@ -428,8 +428,10 @@
channel_class = zhttp_channel
shutup=0
- def __init__ (self, ip, port, resolver=None, logger_object=None):
+ def __init__ (self, ip, port, resolver=None, logger_object=None,
+ fast_listen=True):
self.shutup=1
+ self.fast_listen = fast_listen
http_server.__init__(self, ip, port, resolver, logger_object)
self.shutup=0
self.log_info('%s server started at %s\n'
@@ -460,8 +462,13 @@
def listen(self, num):
# override asyncore limits for nt's listen queue size
- self.accepting = 1
- return self.socket.listen (num)
+ if self.fast_listen:
+ self.accepting = 1
+ return self.socket.listen (num)
+ else:
+ return 0
+
+
class zwebdav_server(zhttp_server):
server_protocol = 'WebDAV'
Modified: Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/component.xml
===================================================================
--- Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/component.xml 2006-08-29 09:34:43 UTC (rev 69832)
+++ Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/component.xml 2006-08-29 12:04:49 UTC (rev 69833)
@@ -19,6 +19,12 @@
receive WebDAV source responses to GET requests.
</description>
</key>
+ <key name="fast_listen" datatype="boolean" default="on">
+ <description>
+ Defines wether the http server should listen to requests immediatelly
+ or only after zope is ready to run
+ </description>
+ </key>
<key name="use-wsgi" datatype="boolean" default="off" />
</sectiontype>
Modified: Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/datatypes.py
===================================================================
--- Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/datatypes.py 2006-08-29 09:34:43 UTC (rev 69832)
+++ Zope/branches/ajung-fast-listen-branch/lib/python/ZServer/datatypes.py 2006-08-29 12:04:49 UTC (rev 69833)
@@ -70,6 +70,7 @@
self.force_connection_close = section.force_connection_close
# webdav-source-server sections won't have webdav_source_clients:
webdav_clients = getattr(section, "webdav_source_clients", None)
+ self.fast_listen = getattr(section, 'fast_listen')
self.webdav_source_clients = webdav_clients
self.use_wsgi = section.use_wsgi
@@ -81,6 +82,7 @@
handler.set_webdav_source_clients(self.webdav_source_clients)
server = self.server_class(ip=self.ip, port=self.port,
resolver=self.dnsresolver,
+ fast_listen=self.fast_listen,
logger_object=access_logger)
server.install_handler(handler)
return server
Modified: Zope/branches/ajung-fast-listen-branch/lib/python/Zope2/Startup/__init__.py
===================================================================
--- Zope/branches/ajung-fast-listen-branch/lib/python/Zope2/Startup/__init__.py 2006-08-29 09:34:43 UTC (rev 69832)
+++ Zope/branches/ajung-fast-listen-branch/lib/python/Zope2/Startup/__init__.py 2006-08-29 12:04:49 UTC (rev 69833)
@@ -100,6 +100,7 @@
self.makePidFile()
self.setupInterpreter()
self.startZope()
+ self.serverListen()
from App.config import getConfiguration
config = getConfiguration()
if not config.twisted_servers:
@@ -211,6 +212,23 @@
ZServer.setNumberOfThreads(self.cfg.zserver_threads)
ZServer.CONNECTION_LIMIT = self.cfg.max_listen_sockets
+
+ def serverListen(self):
+
+
+ servers = []
+ for server in self.cfg.servers:
+ if hasattr(server, 'fast_listen'):
+ # This one has the delayed listening feature
+ if not server.fast_listen:
+ server.fast_listen = True
+ # ATT: should that be a config option? (aj)
+ server.listen( 1024 )
+ else:
+ return
+
+
+
def setupServers(self):
socket_err = (
'There was a problem starting a server of type "%s". '
More information about the Zope-Checkins
mailing list