Interrupting blocking reads

Rob Eden rob at netzilient.com
Wed Feb 21 17:21:04 EST 2001


I have an application that is reading from a number of different files
(well, external process' output streams to be precise). I need to be able to
interrupt the threads, but I don't see a way to do this other than with a
signal.  The problem is, I want to be able to interrupt an individual thread
while possibly leaving the others running.

So can you answer any of these questions:

  1) Is there a way to interrupt a blocking file read other than with a
signal?
  2) Is there a non-blocking file read?  read(0) seems to return no data.
     But it returns right away! (This is useful why?)
  3) Is there a way to get signals to work with multiple threads?
  4) Any other solutions to the problem?

Thanks!


Rob Eden





More information about the Python-list mailing list