bpo-33078 - FIX queue size on pickling error#6119
Conversation
pitrou
left a comment
There was a problem hiding this comment.
Thanks for the fix! A few comments below.
| info('error in queue thread: %s', e) | ||
| return | ||
| else: | ||
| queue_sem.release() |
There was a problem hiding this comment.
Can you add a comment explaining why you need to adjust the semaphore's value?
| q.put(NotSerializable()) | ||
| q.put(True) | ||
| # bpo-30595: use a timeout of 1 second for slow buildbots | ||
| self.assertTrue(q.get(timeout=1.0)) |
There was a problem hiding this comment.
Should you add a check for q.qsize() as well?
| @@ -0,0 +1,2 @@ | |||
| Fix the size handeling in multiprocessing.Queue when a pickling error | |||
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
| q = self.Queue(maxsize=1) | ||
| q.put(NotSerializable()) | ||
| q.put(True) | ||
| self.assertEqual(q.qsize(), 1) |
There was a problem hiding this comment.
Is this check correct? Depending on when the worker thread triggers, it might return 2, no?
There was a problem hiding this comment.
I think it is correct because maxsize=1 so the second q.put should return only once the failure has been triggered.
|
GH-6178 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit e2f33ad) Co-authored-by: Thomas Moreau <thomas.moreau.2010@gmail.com>
The
Queue._feeddoes not properly handle the size of theQueueon errors. This can lead to a situation where theQueueis considered asFullwhen it is empty. Here is a reproducing script:This PR fixes this behavior.
https://bugs.python.org/issue33078