[New-bugs-announce] [issue28650] concurrent.futures.ThreadPoolExecutor: tasks in queue not marked as done
pyfm
report at bugs.python.org
Wed Nov 9 11:05:49 EST 2016
New submission from pyfm:
Hi,
I just realized that the ThreadPoolExecutor's workers do not call task_done() on the work_queue from which they took their task.
Or is there a reason for not calling task_done that I am missing?
Calling task_done decrements the queue's unfinished_tasks counter which could be used to improve the reuse of idle threads (see bquinlan's comment, Lib/concurrent/futures/thread.py:l124).
I am thinking of something like
if self._work_queue.unfinished_tasks > len(self._threads) and len(self._threads) < self._max_workers:
One could still construct cases in which threads are created unnecessarily but it should improve the situation in most cases.
(proposed patch is based on Python-3.6.0b3)
----------
files: thread.py.patch
keywords: patch
messages: 280410
nosy: pyfm
priority: normal
severity: normal
status: open
title: concurrent.futures.ThreadPoolExecutor: tasks in queue not marked as done
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file45409/thread.py.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28650>
_______________________________________
More information about the New-bugs-announce
mailing list