python: using non-blocking IO in Transport classes
python: using non-blocking IO in Transport classes

It turns out that there are some cases where read() after POLLIN is not
safe.  This can happen at a terminal which is currently being read from
by another process (for example, ssh-askpass).

It's also generally unsafe to write() after POLLOUT: as a rule, write()
tries to write() the entire data, and won't return until it has, unless
interrupted by a signal.

On top of that, we were actually trying to write() without even polling.
That means that if we managed to hit the exact edge of the buffer size
(which is likely if we're writing in page-sized multiples, for example)
then we can block straight away.

We really need to be using non-blocking IO, unfortunately.

For comparison purposes, this is what the standard Python Transport
classes all do.

Of course, this means that we're setting stdin/out to non-blocking as
well, which we've had trouble with in the past.  I have some elaborate
ideas for avoiding this, but they can wait.

cockpit-project/cockpit,cockpit-project/cockpit,cockpit-project/cockpit,cockpit-project/cockpit,cockpit-project/cockpit