New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose the unfinished tasks variable #34
Conversation
Sorry, I dont understand your need clean but my guts feel that exposing a new property is not necessary. Both queue.Queue and asyncio.Queue doesn't have such property. Let's imagine you have two chained |
For example if had a web crawler with a queue for URL's to download and a queue for responses to scrape, then I could use a third variable to check whether all work is complete:
With janus I have been avoiding this additional variable by using task_done() and checking ._parent._unfinished_tasks, which works fine, however would prefer not to rely on this private variable. |
Or take a look on crawler example (it's built using slightly different approach than your code). |
Thanks for The 500lines crawler example only uses a single download queue, so avoids the multiple queue problem. I noticed the queue implementation linked makes |
Good point. |
Thanks - see latest commit |
Please fix it. |
Thanks! |
janus 0.3.0 released |
I use
queue.empty() and queue._parent._unfinished_tasks == 0
to check whether a queue is complete and this pull request exposes the _unfinished_tasks variable.My use case is 2 queues that can send work to each other until both are complete - is there a better way to achieve this? Note that I'm not trying to
join()
since a thread should wake up if there is more work to do.