BlockingPool must fit thread_count (#894)
queue_size must be greater than or equal to thread_count, or else the main thread can hang trying to acquire a lock to write sentinel values to the queue during teardown.
This commit is contained in:
committed by
Nick Lang
parent
dd72153a71
commit
fda9d3429c
@@ -347,7 +347,9 @@ def parallel_bulk(
|
||||
class BlockingPool(ThreadPool):
|
||||
def _setup_queues(self):
|
||||
super(BlockingPool, self)._setup_queues()
|
||||
self._inqueue = Queue(queue_size)
|
||||
# The queue must be at least the size of the number of threads to
|
||||
# prevent hanging when inserting sentinel values during teardown.
|
||||
self._inqueue = Queue(max(queue_size, thread_count))
|
||||
self._quick_put = self._inqueue.put
|
||||
|
||||
pool = BlockingPool(thread_count)
|
||||
|
||||
Reference in New Issue
Block a user