[Python-Dev] python sendmsg()/recvmsg() implementation

Kálmán Gergely kalman.gergely at duodecad.hu
Tue Jun 9 16:46:54 CEST 2009


Hello, my name is Greg.

I've just started using python after many years of C programming, and 
I'm also new to the list. I wanted to clarify this
first, so that maybe I will get a little less beating for my stupidity :)

I use python3 and Linux on arch x86 (production will be on x86_64, 
though this shouldn't matter much).

The application that I'm presently working on is a network server. It 
would use separate processes to accept the
connections, and to do the work (much like how apache prefork does). One 
process accept()s on the original socket and
the received socket (client socket) will be read for a request. After 
the request is received and parsed this process (the
controller) will choose one from its' children that is most capable of 
handling the said request. It would then pass the
file descriptor through a socketpair to the appropriate children and go 
handle the next client. All works fine and smooth,
but I realized that I need sendmsg()/recvmsg() to pass the FD. Since 
these are not implemented in the python socket
module, and Linux has no other way to do this, I'm stuck. Fell flat on 
my face, too :)

Browsing the net I've found a patch to the python core 
(http://bugs.python.org/issue1194378), dated 2005.

First of all, I would like to ask you guys, whether you know of any way 
of doing this FD passing magic, or that you know
of any 3rd party module / patch / anything that can do this for me.

Since I'm fairly familiar with C and (not that much, but I feel the 
power) python, I would take the challenge of writing
it, given that the above code is still somewhat usable. If all else 
fails I would like to have your help to guide me through
this process.

Thanks

Kalman Gergely


More information about the Python-Dev mailing list