Condition.wait(0.5) doesn't respect it's timeout

stephane.bisinger at gmail.com stephane.bisinger at gmail.com
Sat Apr 18 11:43:56 EDT 2009


On Apr 18, 4:28 pm, a... at pythoncraft.com (Aahz) wrote:
> Essentially, you use the Queue instead of the Condition.  When you want
> to explicitly give up control in a thread, you get() on the Queue until
> you get an object (with the optional timeout).  When the other thread is
> done processing, it puts an object on the Queue (optionally doing a
> get_nowait() at some point if it wants to make sure the Queue is cleaned
> up).

Yep but as I said I have nothing to pass around

> The critical advantage of using Queue is that you don't have to do the
> acquire()/release() dance.

And neither do I have to using the "with" statement ;)

> It's not so much that there's an advantage to using Queue in this one
> specific case as the fact that you can use Queue for almost everything
> you'd use other kinds of locking mechanisms, so you can reduce your
> mental model for dealing with threading.

That surely helps not making synchronization errors, but I like fully
understanding the concept even if it means being bitten by it! But
thanks for your tips, they will surely be helpful in some other
situation...



More information about the Python-list mailing list