Sharing file descriptors across processes
nas at python.ca
Wed Sep 5 18:15:49 CEST 2001
dave at pythonapocrypha.com wrote:
> I need to somehow "pass" a file descriptor (socket) from one process to
> another process, does anybody know how this can be done? More specifically
> I have a program that accepts an incoming socket and then opens another
> socket to a server, and then acts as a proxy, passing data between the
> two. I would like to find some way to take that pair of sockets and hand
> them off to another worker process.
Can you just fork? If the parent needs to communicate with the child
then open some pipes before you fork. See popen2.py for some clues.
You can also look at http://arctrix.com/nas/python/child_process.py.
More information about the Python-list