diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-15 23:51:58 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-07-15 23:51:58 (GMT) |
commit | dc19c24832fac20402f6cf4d2396c299a73766bb (patch) | |
tree | 310ee12d3a4ccaf1ceb12cda042ec2bb54271673 /Lib/multiprocessing | |
parent | d06a065a441896477f8dc4f5543654f6ba20bb51 (diff) | |
download | cpython-dc19c24832fac20402f6cf4d2396c299a73766bb.zip cpython-dc19c24832fac20402f6cf4d2396c299a73766bb.tar.gz cpython-dc19c24832fac20402f6cf4d2396c299a73766bb.tar.bz2 |
Silence spurious "broken pipe" tracebacks when shutting down a ProcessPoolExecutor.
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/queues.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py index 3324363..4696ccc 100644 --- a/Lib/multiprocessing/queues.py +++ b/Lib/multiprocessing/queues.py @@ -41,6 +41,7 @@ import collections import time import atexit import weakref +import errno from queue import Empty, Full import _multiprocessing @@ -67,6 +68,8 @@ class Queue(object): else: self._wlock = Lock() self._sem = BoundedSemaphore(maxsize) + # For use by concurrent.futures + self._ignore_epipe = False self._after_fork() @@ -178,7 +181,7 @@ class Queue(object): self._thread = threading.Thread( target=Queue._feed, args=(self._buffer, self._notempty, self._send, - self._wlock, self._writer.close), + self._wlock, self._writer.close, self._ignore_epipe), name='QueueFeederThread' ) self._thread.daemon = True @@ -229,7 +232,7 @@ class Queue(object): notempty.release() @staticmethod - def _feed(buffer, notempty, send, writelock, close): + def _feed(buffer, notempty, send, writelock, close, ignore_epipe): debug('starting thread to feed data to pipe') from .util import is_exiting @@ -271,6 +274,8 @@ class Queue(object): except IndexError: pass except Exception as e: + if ignore_epipe and getattr(e, 'errno', 0) == errno.EPIPE: + return # Since this runs in a daemon thread the resources it uses # may be become unusable while the process is cleaning up. # We ignore errors which happen after the process has |