[pypy-issue] [issue1558] Pickling of connection support for Mac OSX and Linux

Anatoly tracker at bugs.pypy.org
Sat Jul 27 01:15:08 CEST 2013

Anatoly <a.vostrjakov at gmail.com> added the comment:

It looks like multiprocessing.reduction is an undocumented module in Python 2.x. 
But people use it. 

I should explain why I need it. When I'm creating a server that is listing 
TCP/IP sockets and create a separate thread for every connection the problem is 
I can't utilize all CPU cores because of Python GIL. In my case it is a real 
problem, I tested. So, I should create a pool of processes to handle connections 
and pass an opened connection to a process that I can send information to a 
client during process execution. So, I reduce socket: h = 
reduce_handle(self.request.fileno()) and pass 'h' to a process. Inside process I 
restore it: fd = rebuild_handle(h); client_socket = socket.fromfd(fd, 
socket.AF_INET, socket.SOCK_STREAM).

  I liked how it works. It is stable in production under Python 2.7.x and I 
don't know why it wasn't documented.

P.S. Some links:
Restore functionality of multiprocessing.reduction in Python 3.3:

Short doc of _multiprocessing module: 

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list