[issue10260] Add a threading.Condition.wait_for() method

Jeffrey Yasskin report at bugs.python.org
Thu Nov 4 03:04:59 CET 2010


Jeffrey Yasskin <jyasskin at gmail.com> added the comment:

On Tue, Nov 2, 2010 at 4:29 AM, Antoine Pitrou <report at bugs.python.org> wrote:
>> I spent some time thinking of a name.  I tried wait_predicate and
>> predicate_wait, but wait_for seemed natural.  Any other ideas?
>> How about wait_until_true?
>
> wait_for is ok IMO.

Agreed.

>> My original method had this as a free function, but I moved it into
>> the Condition because I could see no other kind of primitive that
>> would use it.  I agree that it is unfortunate to pull what is
>> essentially a utility function into the Condition variable, so I am
>> leaning towards keeping it a module function.
>
> I'm not sure I see the point. It's an operation on a Condition variable,
> so it's natural to have it as a Condition method. A module function
> would feel rather weird.

Yeah, it should primarily be used as a Condition method. I was
suggesting implementing that Condition method in terms of a threading
function, which would also help other people trying to, say, mock
Condition objects. But that's not a big deal, and I could be wrong
about whether it's useful at all. As I said earlier, I'm happy with
this patch either way. (Note that Condition.wait_for is helpful to
people mocking Condition anyway, since the number of calls is much
more fixed than the calls to Condition.wait.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10260>
_______________________________________


More information about the Python-bugs-list mailing list