how to check for input on telnet (stdio) from python script

I am trying a way to check for keyboard input during an interactive telnet session on a connectport X so basically i go:

#> py myscript.py

I can ask for user input with the following code (this works):

command = ""
console = code.InteractiveConsole()
while command != "exit":
    command = console.raw_input("what do you want (or type “exit” to quit) $ ")
    command = command.strip()
    handle_command(command)

my problem is console.raw_input() is blocking, which i do not want.

the normal “Python” way of solving is by using the select function on stdio:

    rlist, _, _ = select([sys.stdin], [], [], timeout)
    if rlist:
        s = sys.stdin.readline()
        print s
    else:
        print "No input. Moving on..."

but unfortunately when i try this Python on the CPX gives me an exception telling me sys.stdin has no method “fileno”

Is there a way to solve this problem?

Threading is your answer. There is no fileno to latch onto with select, you’ll need to have a thread monitor/respond to user input, and have a secondary thread do whatever else you need it to do.

Thanks Charlie, i guessed this would be the answer i would get, but honestly was hoping to avoid threading for my simple application.