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

stephane.bisinger at gmail.com stephane.bisinger at gmail.com
Fri Apr 17 21:20:11 EDT 2009


Hi all,
I have a problem with Condition.wait(), it doesn't return after the
given timeout. The thing is that if I try to create a simple program,
it works as expected, but in the actual code, the timeout is not
respected (albeit the notify()s work as expected).
You can find the code I am talking about here:
http://github.com/Kjir/amsn2/blob/6688da4c0b7cc16c0fe04d6d6018bc1b16d992a6/amsn2/gui/front_ends/curses/contact_list.py

If you clone the repository, then you can run the program like this:
$ python amsn2.py -f curses 2>> run.log
and in another term watch for prints with a tail -f run.log (You need
an MSN account). You'll notice that after the initial downloading of
the contact list, there won't be any logs (unless some of your
contacts changes status, which will trigger a notify)

Has anyone the slightest idea on what I may be doing wrong? Or am I
just lucky enough to have stumbled across a bug? Maybe pollution from
another module in other parts of the code? (Like gobject...)

Anyway just for completeness here is a sample program that works for
me:

from threading import Thread
from threading import Condition

def some_func():
    while True:
        cond.acquire()
        while True:
            cond.wait(0.5)
            print "Hello, world!"

cond = Condition()
thread = Thread(target=some_func)
thread.start()

thanks,

Stéphane Bisinger



More information about the Python-list mailing list