Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/multiprocessing/connection.py

    r2 r391  
    44# multiprocessing/connection.py
    55#
    6 # Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
     6# Copyright (c) 2006-2008, R Oudkerk
     7# All rights reserved.
     8#
     9# Redistribution and use in source and binary forms, with or without
     10# modification, are permitted provided that the following conditions
     11# are met:
     12#
     13# 1. Redistributions of source code must retain the above copyright
     14#    notice, this list of conditions and the following disclaimer.
     15# 2. Redistributions in binary form must reproduce the above copyright
     16#    notice, this list of conditions and the following disclaimer in the
     17#    documentation and/or other materials provided with the distribution.
     18# 3. Neither the name of author nor the names of any contributors may be
     19#    used to endorse or promote products derived from this software
     20#    without specific prior written permission.
     21#
     22# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
     23# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     26# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32# SUCH DAMAGE.
    733#
    834
     
    161187        if duplex:
    162188            s1, s2 = socket.socketpair()
     189            s1.setblocking(True)
     190            s2.setblocking(True)
    163191            c1 = _multiprocessing.Connection(os.dup(s1.fileno()))
    164192            c2 = _multiprocessing.Connection(os.dup(s2.fileno()))
     
    173201
    174202else:
    175 
    176     from ._multiprocessing import win32
     203    from _multiprocessing import win32
    177204
    178205    def Pipe(duplex=True):
     
    224251    def __init__(self, address, family, backlog=1):
    225252        self._socket = socket.socket(getattr(socket, family))
    226         self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    227         self._socket.bind(address)
    228         self._socket.listen(backlog)
    229         self._address = self._socket.getsockname()
     253        try:
     254            self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     255            self._socket.setblocking(True)
     256            self._socket.bind(address)
     257            self._socket.listen(backlog)
     258            self._address = self._socket.getsockname()
     259        except socket.error:
     260            self._socket.close()
     261            raise
    230262        self._family = family
    231263        self._last_accepted = None
     
    239271
    240272    def accept(self):
    241         s, self._last_accepted = self._socket.accept()
     273        while True:
     274            try:
     275                s, self._last_accepted = self._socket.accept()
     276            except socket.error as e:
     277                if e.args[0] != errno.EINTR:
     278                    raise
     279            else:
     280                break
     281        s.setblocking(True)
    242282        fd = duplicate(s.fileno())
    243283        conn = _multiprocessing.Connection(fd)
     
    255295    Return a connection object connected to the socket given by `address`
    256296    '''
    257     family = address_type(address)
    258     s = socket.socket( getattr(socket, family) )
     297    family = getattr(socket, address_type(address))
    259298    t = _init_timeout()
    260299
    261300    while 1:
     301        s = socket.socket(family)
     302        s.setblocking(True)
    262303        try:
    263304            s.connect(address)
    264305        except socket.error, e:
     306            s.close()
    265307            if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
    266308                debug('failed to connect to address %s', address)
     
    319361                win32.ConnectNamedPipe(handle, win32.NULL)
    320362            except WindowsError, e:
    321                 if e.args[0] != win32.ERROR_PIPE_CONNECTED:
     363                # ERROR_NO_DATA can occur if a client has already connected,
     364                # written data and then disconnected -- see Issue 14725.
     365                if e.args[0] not in (win32.ERROR_PIPE_CONNECTED,
     366                                     win32.ERROR_NO_DATA):
    322367                    raise
    323368            return _multiprocessing.PipeConnection(handle)
Note: See TracChangeset for help on using the changeset viewer.