Title: multiprocessing example "pool of http servers " fails on windows
Type: behavior Stage: needs patch
Components: Documentation Versions: Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, falsetru, ggenellina, ghum, jnoller, mher.movsisyan, sbt, terry.reedy
Priority: normal Keywords: easy

Created on 2009-04-29 15:38 by ghum, last changed 2014-08-29 23:52 by terry.reedy.

Messages (4)
msg86810 - (view) Author: Harald Armin Massa (ghum) Date: 2009-04-29 15:38
the example from

named "
# Example where a pool of http servers share a single listening socket
does not work on windows.


s = socket.fromfd(fd, family, type_, proto)

in line 156 of

fails, because fromfd is not available on windows. Sad thing: was put into exactly to solve that problem
(i.e. 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:

    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.

msg124431 - (view) Author: Mher Movsisyan (mher.movsisyan) Date: 2010-12-21 13:39
py3k does support socket.fromfd on Windows (#1378)
msg222703 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-10 21:24
Unfortunately #1378 refers to r59004 which is incorrect.  I can't find (due to my limited skill set :( where and when fromfd was included in the Python builds for Windows.  If that can be found and if somebody is prepared to do a backport then this can go forward.
msg226109 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-08-29 23:52
r50094 was for 2.7 (see msg216242, part of #21204 that is a partly a duplicate of this). Running in 2.7.8, the message has changed to
"PicklingError: Can't pickle <type 'thread.lock'>: it's not found as thread.lock"

The example has been removed in 3.x. I think the right 'fix' for 2.7 is to remove the reference to Windows in both comment and code and instead say 'Does not run on Windows'.
Date User Action Args
2014-08-29 23:52:32terry.reedysetassignee: jnoller ->

components: + Documentation, - Library (Lib), Windows
title: multiprocessing - example "pool of http servers " fails on windows "socket has no attribute fromfd" -> multiprocessing example "pool of http servers " fails on windows
keywords: + easy
nosy: + terry.reedy
versions: - Python 3.1, Python 3.2
messages: + msg226109
2014-08-29 23:42:32terry.reedylinkissue21204 superseder
2014-07-11 00:29:47ned.deilysetnosy: + sbt
2014-07-10 21:24:41BreamoreBoysetnosy: + BreamoreBoy
messages: + msg222703
2010-12-21 13:39:22mher.movsisyansetnosy: + mher.movsisyan
messages: + msg124431
2010-08-10 11:38:46floxsetnosy: ggenellina, falsetru, jnoller, ghum
components: + Windows
2010-08-05 03:39:52BreamoreBoysetversions: + Python 3.2, - Python 2.6, Python 3.0
2010-03-17 03:22:42ggenellinasetnosy: + ggenellina
2010-01-20 12:04:11falsetrusetnosy: + falsetru
2009-06-29 13:54:35jnollersetassignee: jnoller
2009-04-29 15:59:43r.david.murraysetversions: + Python 3.0, Python 3.1, Python 2.7
nosy: + jnoller

priority: normal
type: behavior
stage: needs patch
2009-04-29 15:38:01ghumcreate