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/synchronize.py

    r2 r391  
    44# multiprocessing/synchronize.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
     
    5985        self.acquire = self._semlock.acquire
    6086        self.release = self._semlock.release
    61         self.__enter__ = self._semlock.__enter__
    62         self.__exit__ = self._semlock.__exit__
     87
     88    def __enter__(self):
     89        return self._semlock.__enter__()
     90
     91    def __exit__(self, *args):
     92        return self._semlock.__exit__(*args)
    6393
    6494    def __getstate__(self):
     
    182212        self._make_methods()
    183213
     214    def __enter__(self):
     215        return self._lock.__enter__()
     216
     217    def __exit__(self, *args):
     218        return self._lock.__exit__(*args)
     219
    184220    def _make_methods(self):
    185221        self.acquire = self._lock.acquire
    186222        self.release = self._lock.release
    187         self.__enter__ = self._lock.__enter__
    188         self.__exit__ = self._lock.__exit__
    189223
    190224    def __repr__(self):
     
    193227                           self._woken_count._semlock._get_value())
    194228        except Exception:
    195             num_waiters = 'unkown'
     229            num_waiters = 'unknown'
    196230        return '<Condition(%s, %s)>' % (self._lock, num_waiters)
    197231
     
    302336            else:
    303337                self._cond.wait(timeout)
     338
     339            if self._flag.acquire(False):
     340                self._flag.release()
     341                return True
     342            return False
    304343        finally:
    305344            self._cond.release()
Note: See TracChangeset for help on using the changeset viewer.