Wing alters the I/O environment in order to make it possible to keep the
debug process responsive while waiting for I/O. This code mimics the
environment found outside of the debugger, so any code that uses only
Python-level I/O does not need to worry about this change of environment.
There are however several cases that can affect users that bypass
Python-level I/O by doing C/C++ level I/O from within an extension module:
- Any C/C++ extension module code that does standard I/O calls using the
C-level stdin or stdout will bypass Wing's I/O environment
(which affects only Python-level stdin and stdout). This means
that waiting on stdin in C or C++ code will make the debug process
unresponsive to Wing, causing time out and termination of the debug session if
you attempt to Pause or alter breakpoints at that time. In this case,
redirection of I/O to the debugger I/O tool and Debug Probe (in Wing
Pro only) will also not work.
- On all platforms, calling C-level stdin from multiple threads in a multi-threaded
program may result in altered character read order when running under the Wing
debugger.
- When debugging on win32, calling C-level stdin, even in a
single-threaded program, can result in a race condition with Wing's I/O
multiplexer that leads to out-of-order character reads. This is an unavoidable
result of limitations on multiplexing keyboard and socket I/O on this
platform.
If you run into a problem with keyboard I/O in Wing's debugger, you should:
- Turn off Wing's I/O multiplexer by setting the Use sys.stdin
Wrapper preference to False.
- Turn on the Use External Console preference (for details see
External I/O Consoles)
Once that is done, I/O should work properly in the external console, but
the debug process will remain unresponsive to Pause or breakpoint
commands from Wing IDE whenever it is waiting for input, either at the
C/C++ or Python level.
Also, in this case keyboard input invoked as a side effect of using the
Debug Probe will happen through unmodified stdin instead of within
the Debug Probe, even though command output will still appear there.