Sockets accept() in child processes

Thibaut DIRLIK merwin.irc at gmail.com
Thu Apr 12 05:31:08 EDT 2012


Hi,

I'm writing a multiprocess server with Python 3.2 and the multiprocessing
module. Here is my current implementation :

- Main process: select() on a list of server sockets (different ips of the
host, ssl or not, etc)
- Children process : When they get a signal (in fact, a message in a pipe),
they will accept() the server socket

The problem is that after select() returns, I can accept() in the main
process, but in a children process I got a EAGAIN error.
The sockets are non-blocking. It seems that accept() can only be called in
the same process that the one which selected().

This is a problem because I wanted to "decide" which process I should ask
to take the connection
to do some basic load-balacing based on current number of connected client
in each process.

Could someone help me or propose other implementations ?

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120412/ab24e93f/attachment.html>


More information about the Python-list mailing list