[Python-ideas] Supporting already opened sockets in our socket-based server classes (original) (raw)

Tarek Ziadé tarek at ziade.org
Wed Jun 6 09:56:17 CEST 2012


Hello

What about allowing all our socket servers -- from SocketServer to WSGIServer, to run with an existing socket.

The use case is to make it easier to write applications that use the pre-fork model to run several processes against the same socket.

Basically:

I have a working prototype here : https://github.com/tarekziade/chaussette/blob/master/chaussette/server.py (don't look at the code I made it quickly just as a proof of concept)

What I am proposing is the following syntax:

if the host passed to the class is of the form:

 [fd://12](https://mdsite.deno.dev/fd://12)

The class will try to create a socket object against the file descriptor 12, and will not bind() it neither accept() it.

How does that sounds ? If people like the idea I can try to build a patch for 3.x, and I can certainly release a backport for 2.x

Cheers Tarek



More information about the Python-ideas mailing list