Anyone know of a way to get non-blocking keyboard input?
ben.hutchings at roundpoint.com
Tue Feb 27 18:54:55 EST 2001
Jeremy Reed <jpreed00 at MailAndNews.com> writes:
> I am looking to create a telnet client that will, by using the select()
> statment, poll an open socket for data to be received while at the same time
> keep accepting keyboard input from the user.
> I have tried to run a thread in the background that collects input, but I
> never can figure out how to achieve the 'fluidity' that I desire--i.e. no
> stopping for a return-key press.
I think this ought to work for some platforms:
istty = sys.stdin.isatty()
istty = 0
import win32file, win32con
hstdin = win32file._get_osfhandle(sys.stdin.fileno())
modes = (win32file.GetConsoleMode(hstdin)
Unfortunately, GetConsoleMode, SetConsoleMode, and associated
constants don't seem to be included in win32all yet!
Any opinions expressed are my own and not necessarily those of Roundpoint.
More information about the Python-list