diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-06-06 17:35:31 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-06-06 17:35:31 (GMT) |
commit | 176f07dadf80c27348486fdd8017fabbb30da842 (patch) | |
tree | d489214386a5a7d5efec5d157be5783554c6cec2 /Lib/multiprocessing/util.py | |
parent | f068ab830448ea9f78ee0dfbb29c12211d1b6aee (diff) | |
download | cpython-176f07dadf80c27348486fdd8017fabbb30da842.zip cpython-176f07dadf80c27348486fdd8017fabbb30da842.tar.gz cpython-176f07dadf80c27348486fdd8017fabbb30da842.tar.bz2 |
Issue #12040: Expose a new attribute `sentinel` on instances of
:class:`multiprocessing.Process`. Also, fix Process.join() to not use
polling anymore, when given a timeout.
Diffstat (limited to 'Lib/multiprocessing/util.py')
-rw-r--r-- | Lib/multiprocessing/util.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index 30b7a85..7949d3a 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -32,9 +32,11 @@ # SUCH DAMAGE. # +import functools import itertools import weakref import atexit +import select import threading # we want threading to install it's # cleanup function before multiprocessing does @@ -315,3 +317,22 @@ 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, _errors=(EnvironmentError, select.error)): + @functools.wraps(func) + def wrapped(*args, **kwargs): + while True: + try: + return func(*args, **kwargs) + except _errors as e: + # select.error has no `errno` attribute + if e.args[0] == errno.EINTR: + continue + raise + return wrapped + |