[Python-ideas] Expose condition._waiters

Ram Rachum ram at rachum.com
Wed Oct 12 05:26:02 EDT 2016


Hi guys,

I'm writing some code that uses `threading.Condition` and I found that I
want to access condition._waiters. I want to do it in two different parts
of my code for two different reasons:

1. When shutting down the thread that manages the condition, I want to be
sure that there are no waiters on the condition, so I check whether
`condition._waiters` is empty before exiting, otherwise I'll let them
finish and only then exit.

2. When I do notify_all, I actually want to do as many notify actions as
needed until there's a full round of notify_all in which none of the
conditions for any of the waiters have been met. Only then do I want my
code to continue. (It's because these waiters are waiting for resources
that I'm giving them, each wanting a different number of resources, and I
want to be sure that all of them are starved before I get more resources
for them.)

Do you think it'll be a good idea to add non-private functionality like
that to threading.Condition?


Thanks,
Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161012/cdc3e4e8/attachment.html>


More information about the Python-ideas mailing list