serial readline thread IO Error (9, 'Bad file descriptor')

nik nikbaer at gmail.com
Tue Jun 19 13:37:41 EDT 2007


Hi,
How can I close a thread that is waiting on a file/port down
gracefully, and not have an IO error pop up?

I am having trouble closing a thread that is listening to the serial
port. I have a thread that calls uses a pySerial serial port and calls
readline() without a timeout, which is blocking. When I am shutting
down the application I close the serial port, which causes the IO
error: (9, 'Bad file descriptor'). It makes sense that we would get
this error, because it is trying to read off of a closed 'file'. Is
there a better way to close this thread and port down?

Thanks,
Nik




More information about the Python-list mailing list