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

Josiah Carlson josiah.carlson at gmail.com
Wed Jun 10 05:36:19 CEST 2009


On Tue, Jun 9, 2009 at 7:46 AM, Kálmán
Gergely<kalman.gergely at duodecad.hu> wrote:
> 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.

IIRC, this is already implemented in the multiprocessing package,
which comes standard with Python 2.6 and 3.0 .

It looks like the test is disabled in test/test_multiprocessing.py ,
and re-enabling it (on Windows) produces errors that make me think
it's more an issue with the tests than with multiprocessing itself.

Dig into it, see if you can get the tests to pass :)

 - Josiah

> 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
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/josiah.carlson%40gmail.com
>


More information about the Python-Dev mailing list