hello,
I've read a bit about multi thread communication, and found that most people 
use a queue, which makes sense. however in my case I simply have two threads, a 
main thread and one other. the main thread is doing many different things and 
the second thread is receiving numerical data via a serial port.. when data 
comes in, I want to post the data to the main thread so it can use the it. I 
don't want to use a queue because I don't want to lock up my main thread in a 
loop that is always looking at the queue waiting to get something out of it. I 
would prefer to do something like post an event. The alternative would be to 
simply have a method in my main thread called OnResult(data), and when data 
comes in to the second thread I could call main_thread.OnResult(data). This 
would solve my problem, but I'm not sure if that is an ok thing to do... 
calling a main thread method from within a second thread?
 
is there a way to post an event to the main thread from a second thread?
 
Is it ok to pass the main thread (self) into the second thread and have the 
second thread
call a main_thread.OnResult(data) method to pass the data into the main thread? 
I'm not sure how the main thread handles this, my guess is that it can only do 
one thing at a time so it might be exactly that same as 'posting an event'.
 
any thoughts would be much appreciated. thanks!
 
Jeff


      
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to