From fabaf41ecfcb189510efc8229903e025672636ab Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 22 Dec 2011 18:05:54 -0800 Subject: [PATCH] never invalidate a queue with None I saw this *extremely* intermittently (and wasn't able to reproduce it at all), but I think there was a race when invalidating an output queue in the abort() method of PipelineThread. It was possible for a thread's input queue to be invalidated (with val=None) while abort_flag was False (and abort_lock was not held). This would cause coroutines to see a None value when the pipeline was shutting down. Always poisoning a queue when it's invalidated should solve this by making the thread break before sending the value to the coroutine. --- beets/util/pipeline.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beets/util/pipeline.py b/beets/util/pipeline.py index c0dd71086..6adbf160f 100644 --- a/beets/util/pipeline.py +++ b/beets/util/pipeline.py @@ -157,9 +157,9 @@ class PipelineThread(Thread): # Ensure that we are not blocking on a queue read or write. if hasattr(self, 'in_queue'): - _invalidate_queue(self.in_queue) + _invalidate_queue(self.in_queue, POISON) if hasattr(self, 'out_queue'): - _invalidate_queue(self.out_queue) + _invalidate_queue(self.out_queue, POISON) def abort_all(self, exc_info): """Abort all other threads in the system for an exception.