Dio wrote: > #!/usr/bin/env python2 > > from sys import stdin > from select import select > > while 1: > (rr, wr, er) = select([stdin], [], []) > for fd in rr: > print fd > > program block in the first select(), after I type something and "enter > ", it never block in select() again,why? > > Because select blocks until there is something to read on stdin, and as long as there is something to be read on stdin, it will not block. Since your program never reads in the data on stdin, your "enter\n" just sits there waiting to be read, and select always inform you of that fact by returning stdin in the rr list.
If you want select to start blocking again, you must read all bytes from stdin whenever select says there are bytes to be read. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list