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.
This commit is contained in:
Adrian Sampson 2011-12-22 18:05:54 -08:00
parent b44195853c
commit fabaf41ecf

View file

@ -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.