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

    r2 r391  
    44# multiprocessing/forking.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
     
    1036import sys
    1137import signal
     38import errno
    1239
    1340from multiprocessing import util, process
     
    104131        def poll(self, flag=os.WNOHANG):
    105132            if self.returncode is None:
    106                 pid, sts = os.waitpid(self.pid, flag)
     133                while True:
     134                    try:
     135                        pid, sts = os.waitpid(self.pid, flag)
     136                    except os.error as e:
     137                        if e.errno == errno.EINTR:
     138                            continue
     139                        # Child process not yet created. See #1731717
     140                        # e.errno == errno.ECHILD == 10
     141                        return None
     142                    else:
     143                        break
    107144                if pid == self.pid:
    108145                    if os.WIFSIGNALED(sts):
     
    151188    import time
    152189
    153     from ._multiprocessing import win32, Connection, PipeConnection
     190    from _multiprocessing import win32, Connection, PipeConnection
    154191    from .util import Finalize
    155192
     
    168205    TERMINATE = 0x10000
    169206    WINEXE = (sys.platform == 'win32' and getattr(sys, 'frozen', False))
     207    WINSERVICE = sys.executable.lower().endswith("pythonservice.exe")
    170208
    171209    exit = win32.ExitProcess
     
    177215    #
    178216
    179     if sys.executable.lower().endswith('pythonservice.exe'):
     217    if WINSERVICE:
    180218        _python_exe = os.path.join(sys.exec_prefix, 'python.exe')
    181219    else:
     
    305343        Returns prefix of command line used for spawning a child process
    306344        '''
    307         if process.current_process()._identity==() and is_forking(sys.argv):
     345        if getattr(process.current_process(), '_inheriting', False):
    308346            raise RuntimeError('''
    309347            Attempt to start a new process before the current process
     
    324362        else:
    325363            prog = 'from multiprocessing.forking import main; main()'
    326             return [_python_exe, '-c', prog, '--multiprocessing-fork']
     364            opts = util._args_from_interpreter_flags()
     365            return [_python_exe] + opts + ['-c', prog, '--multiprocessing-fork']
    327366
    328367
    329368    def main():
    330369        '''
    331         Run code specifed by data received over pipe
     370        Run code specified by data received over pipe
    332371        '''
    333372        assert is_forking(sys.argv)
     
    367406            d['log_level'] = _logger.getEffectiveLevel()
    368407
    369         if not WINEXE:
     408        if not WINEXE and not WINSERVICE:
    370409            main_path = getattr(sys.modules['__main__'], '__file__', None)
    371410            if not main_path and sys.argv[0] not in ('', '-c'):
Note: See TracChangeset for help on using the changeset viewer.