diff options
author | Richard Oudkerk <shibturn@gmail.com> | 2012-05-10 15:11:12 (GMT) |
---|---|---|
committer | Richard Oudkerk <shibturn@gmail.com> | 2012-05-10 15:11:12 (GMT) |
commit | 59d5404bc79beaa39c76fb26012238b26e9b0166 (patch) | |
tree | 071cc74196e6fcc572c836b6be02a8d9a6bfc276 /Lib/multiprocessing | |
parent | ca5f91b888bc0056fc08d062f65cc783bbba8532 (diff) | |
download | cpython-59d5404bc79beaa39c76fb26012238b26e9b0166.zip cpython-59d5404bc79beaa39c76fb26012238b26e9b0166.tar.gz cpython-59d5404bc79beaa39c76fb26012238b26e9b0166.tar.bz2 |
Issue #14753: Make multiprocessing treat negative timeouts as it did in 3.2
In Python 3.2 and earlier, Process.join() and Connection.poll()
treated negative timeouts as zero timeouts. Earlier versions from
the 3.3 line of development treat them as infinite timeouts.
The patch reverts to the old behaviour.
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/connection.py | 7 | ||||
-rw-r--r-- | Lib/multiprocessing/forking.py | 9 | ||||
-rw-r--r-- | Lib/multiprocessing/util.py | 15 |
3 files changed, 4 insertions, 27 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index acf43b1..56f375d 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -23,8 +23,7 @@ import itertools import _multiprocessing from multiprocessing import current_process, AuthenticationError, BufferTooShort -from multiprocessing.util import ( - get_temp_dir, Finalize, sub_debug, debug, _eintr_retry) +from multiprocessing.util import get_temp_dir, Finalize, sub_debug, debug from multiprocessing.forking import ForkingPickler try: import _winapi @@ -323,8 +322,6 @@ if _winapi: if (self._got_empty_message or _winapi.PeekNamedPipe(self._handle)[0] != 0): return True - if timeout < 0: - timeout = None return bool(wait([self], timeout)) def _get_more_data(self, ov, maxsize): @@ -402,8 +399,6 @@ class Connection(_ConnectionBase): return self._recv(size) def _poll(self, timeout): - if timeout < 0.0: - timeout = None r = wait([self._handle], timeout) return bool(r) diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py index ca03e95..2729afe 100644 --- a/Lib/multiprocessing/forking.py +++ b/Lib/multiprocessing/forking.py @@ -75,12 +75,9 @@ else: # if sys.platform != 'win32': - import select - exit = os._exit duplicate = os.dup close = os.close - _select = util._eintr_retry(select.select) # # We define a Popen class similar to the one from subprocess, but @@ -130,10 +127,10 @@ if sys.platform != 'win32': def wait(self, timeout=None): if self.returncode is None: if timeout is not None: - r = _select([self.sentinel], [], [], timeout)[0] - if not r: + from .connection import wait + if not wait([self.sentinel], timeout): return None - # This shouldn't block if select() returned successfully. + # This shouldn't block if wait() returned successfully. return self.poll(os.WNOHANG if timeout == 0.0 else 0) return self.returncode diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index da99063..9b6dac2 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -295,18 +295,3 @@ class ForkAwareLocal(threading.local): register_after_fork(self, lambda obj : obj.__dict__.clear()) def __reduce__(self): return type(self), () - - -# -# Automatic retry after EINTR -# - -def _eintr_retry(func): - @functools.wraps(func) - def wrapped(*args, **kwargs): - while True: - try: - return func(*args, **kwargs) - except InterruptedError: - continue - return wrapped |