Changeset 391 for python/trunk/Lib/multiprocessing/forking.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/multiprocessing/forking.py
r2 r391 4 4 # multiprocessing/forking.py 5 5 # 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. 7 33 # 8 34 … … 10 36 import sys 11 37 import signal 38 import errno 12 39 13 40 from multiprocessing import util, process … … 104 131 def poll(self, flag=os.WNOHANG): 105 132 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 107 144 if pid == self.pid: 108 145 if os.WIFSIGNALED(sts): … … 151 188 import time 152 189 153 from ._multiprocessing import win32, Connection, PipeConnection190 from _multiprocessing import win32, Connection, PipeConnection 154 191 from .util import Finalize 155 192 … … 168 205 TERMINATE = 0x10000 169 206 WINEXE = (sys.platform == 'win32' and getattr(sys, 'frozen', False)) 207 WINSERVICE = sys.executable.lower().endswith("pythonservice.exe") 170 208 171 209 exit = win32.ExitProcess … … 177 215 # 178 216 179 if sys.executable.lower().endswith('pythonservice.exe'):217 if WINSERVICE: 180 218 _python_exe = os.path.join(sys.exec_prefix, 'python.exe') 181 219 else: … … 305 343 Returns prefix of command line used for spawning a child process 306 344 ''' 307 if process.current_process()._identity==() and is_forking(sys.argv):345 if getattr(process.current_process(), '_inheriting', False): 308 346 raise RuntimeError(''' 309 347 Attempt to start a new process before the current process … … 324 362 else: 325 363 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'] 327 366 328 367 329 368 def main(): 330 369 ''' 331 Run code specif ed by data received over pipe370 Run code specified by data received over pipe 332 371 ''' 333 372 assert is_forking(sys.argv) … … 367 406 d['log_level'] = _logger.getEffectiveLevel() 368 407 369 if not WINEXE :408 if not WINEXE and not WINSERVICE: 370 409 main_path = getattr(sys.modules['__main__'], '__file__', None) 371 410 if not main_path and sys.argv[0] not in ('', '-c'):
Note:
See TracChangeset
for help on using the changeset viewer.