engsol wrote:
I'm working on a s/w test program using python
code. Com1 and com2 play a part. The problem is that the python code
has a lot of work to do...and the results from the hardware under test can
come from either com1 or com2...at any time. It may be a few milliseconds, or several seconds, sometimes minutes, before a response is expected. I'm not sure what timeout value I'd use. Using threads, and re-loading the
timeout values on the fly may be a solution, but I'm not experienced with
threads....and was hoping to avoid them.

I'm with Grant on this: threads in Python are really easy. If you can describe a little more about what you need/would like to do with the serial data when it *does* arrive, and how that relates to the "lot of work" that the rest of the code is doing, I'm sure there are a number of helpful replies just waiting to be written to convince you how easy it really is.

For example, if you need to retrieve the data from the serial
ports right away, so the sending device doesn't block or lose
data, but can afford to just store it for later processing
when the main thread has time, that's only a few lines of
code.

If you actually want to reply immediately, then the only
real question is how you come up with the reply.  If it needs
data from the main thread, we can show you several easy and
appropriate ways to do that with no thread safety issues.

If you're not experienced with threads, there's almost no place
better to start learning than with Python and c.l.p. :-)

-Peter
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to