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, slytomcat
Date 2017-02-20.09:12:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487581944.26.0.570957700938.issue29603@psf.upfronthosting.co.za>
In-reply-to
Content
Class queue.Queue control the number of unfinished tasks via method task_done(). But it is only possible to get the information about all task done (via join() method). 
I'm sure that exposing the number of unfinished tasks (unfinished_tasks class variable) can be very useful in many situations when you need more control over the process.

But it is not good idea to provide write access to this internal variable (as it controls internal queue class status). Better way - provide RO access via class method like qsize or empty. It can be look like this:

    def unfinished(self):
        return self.unfinished_tasks


One example of this method usage: there is not optimal function _adjust_thread_count in concurrent.futures.ThreadPoolExecutor with following comment: 
    # TODO(bquinlan): Should avoid creating new threads if there are more
    # idle threads than items in the work queue.

It can be easily done with following condition:

    if self._work_queue.unfinished() <= len(self._threads):
        return
History
Date User Action Args
2017-02-20 09:12:24slytomcatsetrecipients: + slytomcat, rhettinger
2017-02-20 09:12:24slytomcatsetmessageid: <1487581944.26.0.570957700938.issue29603@psf.upfronthosting.co.za>
2017-02-20 09:12:24slytomcatlinkissue29603 messages
2017-02-20 09:12:23slytomcatcreate