I’m attempting to write a program that waits for readline input, but only for a limited span of time for non-blocking input. From another question on stackoverflow, I was alerted to the Select module. It seemed to fit the bill for me. However, when I attempt to implement it, as follows:
i,o,e = select([sys.stdin],[],[],5)
as described in docs.python.org, (I’m only interested in input, and in this example, a timeout of 5 seconds) I get an error message reading:
TypeError: select() takes at most 3 arguments (4 given)
If I instead call it as:
i,o,e = select([sys.stdin],[],[])
Then I get:
ValueError: list of cases must be same length as list of conditions
with a calling module of /usr/lib/pymodules/python2.7/numpy/lib/function_base.py line 718.
I’m running ubuntu 11.10, with Python 2.7.2+.
Can anyone shed some light on this for me? I really need the timeout functionality.
Sounds like you’re calling the numpy.select function , but you want the select.select function. Import them accordingly.