pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.41k stars 369 forks source link

Speed up reading from in_stream #983

Open meshy opened 10 months ago

meshy commented 10 months ago

By only sleeping when the input stream is waiting, this change ensures that we don't delay when there is still data available to read.

This provides a significant speed improvement to scripts which are passing a populated stream of data, rather than awaiting user input from stdin.

I had to modify an existing test to ensure that it continued to see sleeps.

I have also changed the default chunk read size to match Python's default, which is the "“Preferred” blocksize for efficient file system I/O." (Of course, I'm happy to revert this if it makes the PR more palatable.)

Fixes https://github.com/pyinvoke/invoke/issues/774