check if there is data in stdin without blocking
hg
hg at nospam.org
Mon Jan 15 03:55:50 EST 2007
Laurent Pointal wrote:
> 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.
Well I'm testing under Linux but need support under Windows ... is there any
way to poll stdin somehow under both plateform ?
thanks,
hg
More information about the Python-list
mailing list