bpo-30414: multiprocessing.Queue._feed do not break from main loop on exc (#1683)
* bpo-30414: multiprocesing.Queue._feed do not break from main loop on exc Queue background running thread was not handling exceptions correctly. Any exception occurred inside thread (putting unpickable object) cause feeder to finish running. After that every message put into queue is silently ignored. * bpo-30414: multiprocesing.Queue._feed do not break from main loop on exc Queue background running thread was not handling exceptions correctly. Any exception occurred inside thread (putting unpickable object) cause feeder to finish running. After that every message put into queue is silently ignored.
This commit is contained in:
parent
7ff1e88a57
commit
bc50f03db4
@ -221,8 +221,8 @@ class Queue(object):
|
|||||||
else:
|
else:
|
||||||
wacquire = None
|
wacquire = None
|
||||||
|
|
||||||
try:
|
|
||||||
while 1:
|
while 1:
|
||||||
|
try:
|
||||||
nacquire()
|
nacquire()
|
||||||
try:
|
try:
|
||||||
if not buffer:
|
if not buffer:
|
||||||
@ -256,14 +256,12 @@ class Queue(object):
|
|||||||
# may be become unusable while the process is cleaning up.
|
# may be become unusable while the process is cleaning up.
|
||||||
# We ignore errors which happen after the process has
|
# We ignore errors which happen after the process has
|
||||||
# started to cleanup.
|
# started to cleanup.
|
||||||
try:
|
|
||||||
if is_exiting():
|
if is_exiting():
|
||||||
info('error in queue thread: %s', e)
|
info('error in queue thread: %s', e)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
_sentinel = object()
|
_sentinel = object()
|
||||||
|
|
||||||
|
@ -752,6 +752,20 @@ class _TestQueue(BaseTestCase):
|
|||||||
# Windows (usually 15.6 ms)
|
# Windows (usually 15.6 ms)
|
||||||
self.assertGreaterEqual(delta, 0.170)
|
self.assertGreaterEqual(delta, 0.170)
|
||||||
|
|
||||||
|
def test_queue_feeder_donot_stop_onexc(self):
|
||||||
|
# bpo-30414: verify feeder handles exceptions correctly
|
||||||
|
if self.TYPE != 'processes':
|
||||||
|
self.skipTest('test not appropriate for {}'.format(self.TYPE))
|
||||||
|
|
||||||
|
class NotSerializable(object):
|
||||||
|
def __reduce__(self):
|
||||||
|
raise AttributeError
|
||||||
|
with test.support.captured_stderr():
|
||||||
|
q = self.Queue()
|
||||||
|
q.put(NotSerializable())
|
||||||
|
q.put(True)
|
||||||
|
self.assertTrue(q.get(timeout=0.1))
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -341,6 +341,9 @@ Extension Modules
|
|||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- bpo-30414: multiprocessing.Queue._feed background running
|
||||||
|
thread do not break from main loop on exception.
|
||||||
|
|
||||||
- bpo-30003: Fix handling escape characters in HZ codec. Based on patch
|
- bpo-30003: Fix handling escape characters in HZ codec. Based on patch
|
||||||
by Ma Lin.
|
by Ma Lin.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user