Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
passing a socket to a subprocess in windows
Daniel Platz
3/16/2010 5:10:00 PM
Hello!
I have a problem with passing a socket to a subprocess in windows. It
works in Linux and for windows there is a workaround in the Python
doc. However, this workaround does not work. It was already noted by
other people and they Python issue tracker
http://bugs.python.org...
***************************************************************************************************************
the example from
http://docs.python.org/library/multiprocessing.html?highlight=multiprocessing#module-multi...
named "
# Example where a pool of http servers share a single listening socket
#
"
does not work on windows.
Reason:
s = socket.fromfd(fd, family, type_, proto)
in line 156 of reduction.py
fails, because fromfd is not available on windows. Sad thing:
reduction.py was put into processing.py exactly to solve that problem
(i.e. reduction.py is provided as workaround for socket.fromfd not
available on windows, from the documentation:
if sys.platform == 'win32':
import multiprocessing.reduction
# make sockets pickable/inheritable
the solution within processing was:
try:
fromfd = socket.fromfd
except AttributeError:
def fromfd(fd, family, type, proto=0):
s = socket._socket.socket()
_processing.changeFd(s, fd, family, type, proto)
return s
but: _multiprocessing has no longer a method changeFd.
Harald
***********************************************************************************************************************
Has someone information about this or can help me to solve the
problem.
Thanks in advance
Daniel
1 Answer
Gabriel Genellina
3/16/2010 10:39:00 PM
0
En Tue, 16 Mar 2010 14:10:16 -0300, Daniel Platz
<mail.to.daniel.platz@googlemail.com> escribió:
> I have a problem with passing a socket to a subprocess in windows. It
> works in Linux and for windows there is a workaround in the Python
> doc. However, this workaround does not work. It was already noted by
> other people and they Python issue tracker
>
>
http://bugs.python.org...
Unfortunately I cannot test it at this moment, but around line 360 in
socketmodule.c:
#if defined(MS_WINDOWS) || defined(__BEOS__)
...
#define NO_DUP /* Actually it exists on NT 3.5, but what the heck... */
#endif
you could try removing that #define NO_DUP and recompiling. socket.fromfd
should appear, and hopefully socket objects can now be sent thru the
multiprocessing connection.
(I cannot see how the example could have actually worked on Windows, maybe
I'm missing something. Perhaps
http://bugs.python.org...
broke
this.)
--
Gabriel Genellina
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
passing a socket to a subprocess in windows
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password