[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-22 Thread slytomcat
slytomcat added the comment: I've closed pull request on GitHub. -- stage: -> resolved status: open -> closed ___ Python tracker ___

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-22 Thread slytomcat
slytomcat added the comment: I can't fully agree with this: >Queue objects are primarily about managing a queue of inputs. >Monitoring and managing consumers is another (mostly orthogonal) realm. Monitoring of consumers is already added via task_done() and join() methods. At least this two

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: > 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

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-21 Thread slytomcat
slytomcat added the comment: num_threads - unfinished() = the estimation for number of idle threads. -- ___ Python tracker ___

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-21 Thread slytomcat
slytomcat added the comment: One more problem that adjusting of number of threads is performed exactly after placing the new task in the queue. In in some cases we can find that qsuze <> 0 but it doesn't mean that there is no idle threads. It can be equal to 1 (just queued task) as no threads

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-21 Thread slytomcat
slytomcat added the comment: Not exactly there are 3 cases: If qsize <> 0 it means there is no idle consumers threads, all of them must be busy: we need to create one more. No doubt. If qsize = 0 it means one of two cases: - all consumers threads are busy: we need to create one more -

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Should avoid creating new threads if there are more # idle threads than items in the work queue. Shouldn't this just check to see if qsize() is greater than zero? That would mean that there are no idle threads. I'm not seeing why there would be any

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-21 Thread slytomcat
slytomcat added the comment: 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.

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Raymond. -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I'm sure that exposing the number of unfinished tasks > (unfinished_tasks class variable) can be very useful in many situations Sorry, but I don't share your certainty of the usefulness of this method. Since the task_done/join API was added many years

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-20 Thread slytomcat
Changes by slytomcat : -- type: -> enhancement ___ Python tracker ___ ___

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-20 Thread slytomcat
Changes by slytomcat : -- pull_requests: +158 ___ Python tracker ___ ___ Python-bugs-list

[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-20 Thread slytomcat
New submission from slytomcat: 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