Nathaniel J. Smith
Nathaniel J. Smith
Oh, here's another fun issue to keep in mind: [`TextIOWrapper` objects are not thread safe](https://docs.python.org/3/library/io.html#multi-threading). This means that if we naively `wrap_file(sys.std...)`, then the resulting object is unsafe to call...
Whoops, I don't mean SIGTSTP, I mean SIGTTIN and SIGTTOU. And apparently both writing and reading can trigger suspension.
Hmm, here's another trick, but it might not be widely applicable enough to be worthwhile: the `send` and `recv` syscalls accept a `flags` argument, and one of the flags you...
> What about task-local storage? Task-local storage would be useful if there were some way to give each task its own private stdin, stdout, etc., but.... I'm not sure what...
Update: Apparently I was wrong! On Windows, It is possible to read/write to the console without doing blocking `read`/`write` in threads. Which is good, because `ReadFile` and `WriteFile` on the...
Also, note for reference: looking at the python-prompt-toolkit code, it appears that the way they do async interactive applications on Unix is to `select` to see if a standard stream...
Further Windows update: while I still can't find any references to `CancelSynchronousIo` working on console reads through web search, @eryksun claims [in this message](http://bugs.python.org/issue29926#msg297286) that it does with some caveats....
libuv has [a clever trick!](http://code.saghul.net/index.php/2016/05/24/libuv-internals-the-osx-select2-trick/) If you want to set stdin/stdout/stderr non-blocking, and it's a tty, then you can use `os.ttyname` to get the device node for this tty and...
@remleduff has made a remarkable discovery: on Linux, libuv's clever trick of re-opening the file can actually be done *on anonymous pipes too*, by opening `/proc/self/fd/NUM`. I guess this makes...
I also spent some time trying to figure out if there was a way to making blocking I/O cancellable. ~~I don't think there is.~~ maybe there is? The first idea...