vwait in Python?

Steve Holden sholden at holdenweb.com
Thu Mar 28 12:57:02 EST 2002


"Ken Guest" <kwg at renre-europe.com> wrote in message
news:mailman.1017331196.5311.python-list at python.org...
> On Thu, 2002-03-28 at 11:37, Ken Guest wrote:
> > Anybody know if there's an equivalent to TCL's vwait keyword in Python?
>
> So is there no way, short of a 2 line while statement, to have code
> hang around until the value of some variable has been changed?
>
> I have tried using variations of the simple while statement, but they
> only result in the application hanging (going into an infinite loop
> no doubt).
>
Now you've explained the REAL problem, of course it's easier to see how to
solve it.

There are various synchronization primitives which you might use for this
purpose. The simplest is mutex, but that doesn't support threading and your
question kind of implies that the variable will be changed in another
thread.

Something else you haven't explained is whether the code which changes the
variable's value is aware that there is another component waiting for it to
change (in other words, are you working with code you can modify, or must
you just wait for the value to change).

In multi-threaded applications the Queue module allows you to synchronize
different threads quite effectively.

regareds
 Steve







More information about the Python-list mailing list