Way to unblock sys.stdin.readline() call
Cédric Lucantis
omer at no-log.org
Sat Jun 21 11:46:33 EDT 2008
Le Saturday 21 June 2008 15:26:53 joamag, vous avez écrit :
> HI,
>
> Is there any possible way to unblock the sys.stdin.readline() call
> from a different thread.
> Something like sys.stdin.write() but that would actually work ...
> something to put characters in the stdin...
>
Do you mean setting stdin in non-blocking mode ? On unix you can do it with
the fcntl module (you'll find more infos in the libc docs) :
fcntl.fcntl(sys.stdin, fcntl.F_SETFL, os.O_NONBLOCK)
and catch IOErrors with errno = EAGAIN. But I don't know how to do it in a
portable way, suggestions welcome :)
--
Cédric Lucantis
More information about the Python-list
mailing list