Passing file descriptors in Python?
Tres Seaver
tseaver at starbase.neosoft.com
Sat Oct 2 11:17:53 EDT 1999
In article <37f5aa20.6716735 at news.supernews.com>,
Dan <puter_programmer at yahoo.com> wrote:
>
>
>I suppose I should clarify my request. :-)
>
>What I want to do is to have a parent process spawn off a child
>process which then waits for new file descriptor (socket) to come from
>the parent. The parent after it spawns several children will wait
>listen on a socket for new connections which it will pass to one of
>the child processes after the connection has been established.
>
>My goal here is to make a Python based web server that will run on
>more than one processor simultaniously. I've already built one that
>uses threading but unfortunately Python has a global interpreter lock
>which keeps two threads from running at the same time on a
>multi-processor machine. So I need to go with a multi-process scheme
>in order to take advantage of a multi-processor system but the problem
>is that I'm having a difficult time figuring out how to pass a file
>descriptor from one process ro another since the only sample code I
>can find is written in C.
The bible for this kind of stuff is W. S. Stevens'
_Unix_Network_Programming_. Volume 1 of the second edition, section 27.9,
has exactly the kind of setup you describe. The mechanism used is quite
arcane: essentially, the two processes use a Unix-domain socket to pass
the descriptor via sendmsg() / recvmsg(); exact details depend on the
actual kernel used.
--
---------------------------------------------------------------
Tres Seaver tseaver at palladion.com 713-523-6582
Palladion Software http://www.palladion.com
More information about the Python-list
mailing list