Reading asynchronous data from a serial device

hopper at omnifarious.mn.org.bbs hopper at omnifarious.mn.org.bbs
Mon Jul 17 14:50:03 EDT 2000


In article <8kuvg0$kg2$1 at nnrp1.deja.com>, julesk24 at my-deja.com wrote:
>
> 1)  Is there any (easy) way for me to cause the thread to exit (not
> just join the processes) after a timeout on a read?

I believe you can start the thread as a daemon thread and not have the
join problem.  When the thread exits, it just disappears and doesn't wait
for its parent thread to notice.

I'm not sure how to start it as a daemon thread.

> 2)  Is there a better way of reading for data (without starting my own
> thread for the read process and then trying to exit out of the thread
> after a period of time)?

Yes.  Use a select(2), or poll(2) based mechanism.  I believe the asyncore
module handles this for you.  I will also be adding a python wrapper to my
C++ StreamModule (http://www.sourceforge.net/projects/strmod) system
someday, and that should also nicely handle the problem.

Have fun (if at all possible),
--Eric Hopper



More information about the Python-list mailing list