Re:Create Python GUIs using HTML (And Webkit and GTK)
by audidude on Thursday April 30, 2009 @06:08PM
(#587652)
Instead, use a "message reply" concept. For example, for your data you could send a tuple with a callback or a condition.
Then block on the condition, and have the lambda/delegate in the idle thread signal the condition. Make sure you hold the lock for the conditions mutex before sending the message though so that it is not a race condition.
#Sender
callback = SomeFunc
mutex.lock()
def worker():
# ran in main
callback()
mutex.lock()
cond.signal()
mutex.unlock()
Then block on the condition, and have the lambda/delegate in the idle thread signal the condition. Make sure you hold the lock for the conditions mutex before sending the message though so that it is not a race condition.
#Sender
callback = SomeFunc
mutex.lock()
def worker():
send_msg_to_idle(0, worker)cond.wait()
mutex.unlock()