[Python-ideas] BufferedIO and detach

Robert Collins robertc at robertcollins.net
Tue Mar 5 11:03:07 CET 2013

On 5 March 2013 22:22, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Le Tue, 5 Mar 2013 20:39:55 +1300,
> Robert Collins
> <robertc at robertcollins.net> a écrit :
>> On 5 March 2013 20:31, Antoine Pitrou
>> <solipsis at pitrou.net> wrote:
>> > On Tue, 5 Mar 2013 10:50:01 +1300
>> > I didn't know about that. I wonder, what happens if the standard
>> > input is redirected?
>> > Also, is it able to read actual raw bytes? INPUT_RECORD looks rather
>> > specialized:
>> > http://msdn.microsoft.com/en-us/library/ms683499%28v=vs.85%29.aspx
>> I don't know; cygwin's source may, or we could get someone with a
>> Windows machine to do some testing.
> Apparently you need ReadConsole to read bytes, not ReadConsoleInput:
> http://msdn.microsoft.com/en-us/library/ms684958%28v=vs.85%29.aspx
> However, none of those functions is technically non-blocking. You can
> poll the console using one of the wait functions, but there is an
> important caveat for ReadConsole:
> « If the input buffer contains input events other than keyboard events
> (such as mouse events or window-resizing events), they are discarded.
> Those events can only be read by using the ReadConsoleInput function. »
> So it seems ReadConsole can block even though you think some data is
> available.


Suggests you can indeed get key events from ReadConsoleInput. I don't
know what redirected input does in that case.

Anywhich way, its some future work that doesn't affect what can be done now.

Thanks for the extended discussion, I think the next stage is for me
to make a timeslice to put a patch together.


Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Cloud Services

More information about the Python-ideas mailing list