summaryrefslogtreecommitdiff
path: root/wsgitools/scgi/asynchronous.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/scgi/asynchronous.py')
-rw-r--r--wsgitools/scgi/asynchronous.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py
index 75f1ff0..e1dbcc6 100644
--- a/wsgitools/scgi/asynchronous.py
+++ b/wsgitools/scgi/asynchronous.py
@@ -191,7 +191,7 @@ class SCGIServer(asyncore.dispatcher):
multiple threads."""
def __init__(self, wsgiapp, port, interface="localhost", error=sys.stderr,
maxrequestsize=None, maxpostsize=None, blocksize=None,
- config={}):
+ config={}, reusesocket=None):
"""
@param wsgiapp: is the wsgi application to be run.
@type port: int
@@ -215,8 +215,16 @@ class SCGIServer(asyncore.dispatcher):
@type config: {}
@param config: the environ dictionary is updated using these values for
each request.
+ @type reusesocket: None or socket.socket
+ @param reusesocket: If a socket is passed, do not create a socket.
+ Instead use given socket as listen socket. The passed socket
+ must be set up for accepting tcp connections (i.e. AF_INET,
+ SOCK_STREAM with bind and listen called).
"""
- asyncore.dispatcher.__init__(self)
+ if reusesocket is None:
+ asyncore.dispatcher.__init__(self)
+ else:
+ asyncore.dispatcher.__init__(self, reusesocket)
self.wsgiapp = wsgiapp
self.error = error
@@ -229,10 +237,11 @@ class SCGIServer(asyncore.dispatcher):
self.conf["blocksize"] = blocksize
self.conf["config"] = config
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
- self.set_reuse_addr()
- self.bind((interface, port))
- self.listen(5)
+ if reusesocket is None:
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.set_reuse_addr()
+ self.bind((interface, port))
+ self.listen(5)
def handle_accept(self):
"""asyncore interface"""