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

stephane.bisinger at gmail.com stephane.bisinger at gmail.com
Sun Apr 19 09:59:46 EDT 2009


On Apr 18, 8:29 pm, Piet van Oostrum <p... at cs.uu.nl> wrote:
> 2. Importing in a thread is discouraged. I think it is cleaner to put
>    the import sys in the top of the module.

Yes I know I shouldn't import inside of threads, but that is something
that is going away, it's just for debugging this issue.

On Apr 19, 2:31 pm, Piet van Oostrum <p... at cs.uu.nl> wrote:
> I looked at it more closely, and I found that the Condition.wait is
> stuck on obtaining the GIL while the main thread executes the gobject
> main loop. Therefore it also blocks on notifications, not only on the
> timeout.

Ah-ha! My suspicions were right, then, I remembered something about
gobject being incompatible with python threads... but I couldn't find
anything in the docs, not even those of gobject, so I assumed my
memory was failing me...

> It appears that GTK and Python threads are incompatible UNLESS you call
> gtk.gdk.threads_init() before gtk.main(). In your case you can do it
> after the import gtk in contact_list.py. Then it should work.

I'll try to do that

> By the way, I wonder why you need a timeout in your wait. I think the
> notifications should be sufficient to keep the gui updated.

The reason is simple: when first downloading the contactss list,  I
receive a swarm of *Updated() calls, so if I redraw every time I get a
very bad visual effect and I waste a lot of CPU redrawing something
that will change in a very very short time. Hence the time
constraint... I couldn't come up with something smarter, so...

Anyway I wanted to really thank you for your time and your precious
advice, I really appreciate it!



More information about the Python-list mailing list