Threading.Condition problem

Gabriel Rossetti gabriel.rossetti at arimaz.com
Fri Jul 10 11:57:23 CEST 2009


Hello everyone,

I wrote a small example that listens for xmpp msgs in a thread. The main 
program calls a function that blocks (using Condition.wait) until a msg 
has been received and then returns the msg. When a msg arrives, it is 
put in a variable in the thread's object, it then calls the notify() 
attr on the Condition object. For some reason, this doesn't work, the 
thread gets the msg, tries to notify the Condition object, fails because 
the lock has not been acquired yet and blocks. I tried ignoring the 
failure, thinking that since it has not been acquired yet then when it 
is, it will get the msg right away and never call Condition.wait, thus 
not causing any problems, but this does not work either. Does someone 
know what I am doing wrong? I attached the code to this msg.

Thank you,
Gabriel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmpp_client.py
Type: text/x-python
Size: 6127 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090710/1645640b/attachment.py>


More information about the Python-list mailing list