Reading asynchronous data from a serial device

julesk24 at my-deja.com.bbs julesk24 at my-deja.com.bbs
Mon Jul 17 09:00:03 EDT 2000


I am attempting to write a program (to run on a linux box) in python
which communicates to a device via a serial port.  The problem is that
the device is not reliable in responding when expected.  Therefore, I
have many reads timeout.  I am relatively new to the world of multiple
threads so I am probably making many mistakes.  My current approach is
to use a separate thread for the read and then to join() the thread
back into the main thread if the read is not sucessful within the given
amount of time.  The end result is hundreds of hung processes and an
eventual segmentation fault (the program needs to be designed to run
for days).  My questions are:

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?

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)?

I have read through the newsgroups, but I haven't found anything which
specifically answers my questions.  Thanks to anyone who can answer my
questions!

Julie Kempton
jmk11 at duke.edu


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list