Le mercredi 19 février 2014 17:32:25 UTC+1, Victor Stinner a écrit : > > I'm not sure that I understand correctly. stdin are stdout have a > different file descriptor: 0 and 1. But in case of PTY, it looks like > 0 and 1 are the same file: os.path.samestat(os.fstat(0), os.fstat(1)) > is True. >
This is because the file descriptor is copied, this is how forkpty works. Maybe you can take a look at this line of pexpect: https://github.com/noahspurrier/pexpect/blob/master/pexpect.py#L630 It looks like writing data into the PTY raises a read > event, and os.read() on the file descriptor returns the written data. > This is only the case when the pty is in canonical mode. (The pty implements some line editing/buffering functionality itself.) Maybe you want to set the pty in raw mode first. Everything seems more logical then: http://docs.python.org/2/library/tty.html#tty.setraw To the questions considering asyncio itself, I don't have a real answer.