[issue10260] Add a threading.Condition.wait_for() method
report at bugs.python.org
Mon Nov 1 16:22:51 CET 2010
Jeffrey Yasskin <jyasskin at gmail.com> added the comment:
* This method will confuse some people who will think that cond.wait(pred) will wake up when pred becomes true regardless of whether they call cond.notifyAll(). You should warn them about this in the documentation. (This confusion happens inside Google, despite our documentation, but the method's worth having even though not everyone will read the docs.) You should also mention that 'predicate' runs with the Condition acquired.
Then +1 whether or not you do anything in response to the below comments.
* There's a small risk of confusion with C++0x's wait_for method, which behaves like the current Condition.wait (waiting for a timeout). They used "wait_for" because they also have a "wait_until" that waits until a deadline. I don't think this potential confusion is a big deal.
* This expands the interface needed to duck-type as a Condition. Maybe you could also add a threading.wait_for(Condition, predicate, timeout) that implements the same thing using just the Condition's .wait() method? I'm not certain that'll be the best name as a threading method, but I don't have a better proposal.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list