This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author slytomcat
Recipients rhettinger, serhiy.storchaka, slytomcat
Date 2017-02-21.08:25:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487665526.55.0.187648411778.issue29603@psf.upfronthosting.co.za>
In-reply-to
Content
Raymond, Serhiy, thanks for your opinions.

I agree that this method like empty, full, and qsize returns information that may be out-of-date in time of its usage.

But like those empty, full, and qsize it provides information that helps to make some decisions.

What I disagree that this information can be correctly estimated based on qsize and number of parallel consumers as there is no information what exactly consumers do at the moment. Such estimation will be absolutely useless for a decision making.

In the example (see https://github.com/slytomcat/cpython/commit/ea313986d86c083e81624fbc8a7ab6a75784e15d) we need to estimate the number of unfinished tasks and comparing it to the number of active threads we can decide: should we create a new thread or not. There is no reason to wait until all tasks done (via join) we need to make decision in working conditions.

Actually I've implemented this solution (Queue.unfinished + modified concurrent.futures.ThreadPoolExecutor) in my project (see https://github.com/slytomcat/yandex-disk-client) and it works perfectly: the number of working threads is increasing only on massive flow of tasks, while weak flow of tasks keeps low number of working threads.
And even when Queue.unfinished gives wrong (outdated) information, it can lead to creation one new thread that is not really required at the moment. That is not a big mistake, I suppose (comparing to creation all N threads during placing first N tasks in queue without considering the volume of concurrent tasks).
History
Date User Action Args
2017-02-21 08:25:26slytomcatsetrecipients: + slytomcat, rhettinger, serhiy.storchaka
2017-02-21 08:25:26slytomcatsetmessageid: <1487665526.55.0.187648411778.issue29603@psf.upfronthosting.co.za>
2017-02-21 08:25:26slytomcatlinkissue29603 messages
2017-02-21 08:25:25slytomcatcreate