S
stephane.bisinger
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/6...6/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
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/6...6/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