nonblocking reads in windows?
joec at mill.co.uk
Fri Aug 23 13:25:01 CEST 2002
Thomas Jensen wrote:
> Hello Joe,
> Joe Connellan wrote:
> > I have opened a serial port and if there is nothing there to be read
> > os.read() hangs whereas I want it to return "".
> > if I try to open the fd with
> > port = os.open("COM1", os.O_RDWR | os.O_NONBLOCK)
> > I get an AttributeError saying that os has no attribute O_NONBLOCK. And
> > the windows select module doesn't support filehandles so it seems I
> > cannot do it that way either.
> > Is there any way I can do this on windows?
> I don't use Windows much, but perhaps you could solve this using a
> thread and a queue? (modules threading and Queue)
I had a look at threads for this, I thought that if I put the read in a
thread I could then kill it if it hadn't read anything after 5 secs. But I
could not work out how to kill the thread - you can't kill it directly and I
don't think you can send it a signal (would it even service the signal if
it's blocked by an io read?). No doubt there would be a better way of doing
it than this so if you have any ideas?
> Best Regards
> Thomas Jensen
> (remove underscore in email address to mail me)
More information about the Python-list