check if there is data in stdin without blocking
Laurent Pointal
laurent.pointal at limsi.fr
Mon Jan 15 10:48:06 EST 2007
hg a écrit :
> hg wrote:
>
>> Hi,
>>
>> Is there a way ? ... select ?
>>
>>
>>
>> hg
> PS:
>
> import sys
> import select
>
> l_r = select.select([sys.stdin],[],[],0)
>
> gives me:
> File "select.py", line 2, in ?
> import select
> File "/home/philippe/Desktop/select.py", line 4, in ?
> l_r = select.select([sys.stdin],[],[],0)
> TypeError: 'module' object is not callable
>
>
Wont work under Windows:
>>> help(select.select)
...<zip>...
*** IMPORTANT NOTICE ***
On Windows, only sockets are supported; on Unix, all file descriptors.
If under Unix, maybe sys.stdin.fileno() is a valid descriptor for
select. Just test it.
And if under Windows, you may take a look at
22.1 msvcrt - Useful routines from the MS VC++ runtime
22.1.2 Console I/O
kbhit( ) - Return true if a keypress is waiting to be read.
More information about the Python-list
mailing list