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.

classification
Title: Add pending() query method to Queue.Queue
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Add timeout parameter to Queue.join()
View: 9634
Assigned To: Nosy List: mcjeff, ncoghlan
Priority: normal Keywords:

Created on 2012-04-04 02:23 by ncoghlan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg157453 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-04-04 02:23
The task management API in the Queue module doesn't let you check to see if there are any pending tasks still being processed.

A pending() query API (analagous to empty() and full()) would resolve that problem.

The use case is for a process that terminates when all current jobs are complete, but should immediately start processing any *new* jobs that arrive while waiting for the old ones. Using the current Queue.join() method would fail the second requirement (since the blocking calls means that no new jobs could be added while waiting for the old ones to finish).
msg157456 - (view) Author: Jeff McNeil (mcjeff) * Date: 2012-04-04 02:55
I looked at doing this. The empty() and full() methods are marked with a disclaimer stating they're likely to be removed at some point?

I'm curious, does just checking the value of <Queue>.unfinished_tasks satisfy the requirement? It could still easily be non-zero even if the queue itself is empty, signifying work in progress.  Another option might be to allow non-blocking use of join()?
History
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58692
2012-04-04 02:55:35mcjeffsetnosy: + mcjeff
messages: + msg157456
2012-04-04 02:41:23ncoghlansetstatus: open -> closed
superseder: Add timeout parameter to Queue.join()
resolution: duplicate
2012-04-04 02:24:15ncoghlansetstage: needs patch
type: enhancement
components: + Library (Lib)
versions: + Python 3.3
2012-04-04 02:23:36ncoghlancreate