Skip to content

command (runner) & conquer

Compare
Choose a tag to compare
@deajan deajan released this 07 Sep 17:11
· 262 commits to master since this release

Major release v1.2.0

This release is a major refactor of the stdout capture methods employed within command_runner.
So we jump from v0.7.0 to v1.2.0 since we have a major rework, and minor fixes too.
Since we include a critical fix, everybody is encouraged to migrate to this version.

Critical fixes

  • There was a quite rare but annoying issue where the process finished, but there was still output to read in the pipe reader queue, rendering partial outputs. This has been fully refactored, and a test with 2500 rounds of file reading was added

Features

  • There are now two distinct methods to capture output
    • Spawning a thread to enforce timeouts, and using process.communicate() (monitor method)
    • Spawning a thread to readlines from stdout pipe to an output queue, and reading from that output queue while enforcing timeouts (polller method)
  • On the fly output (live_output=True) option is now explicit (uses poller method only)
  • Returns partial stdout output when timeouts are reached
  • Returns partial stdout output when CTRL+C signal is received (only with poller method)

Misc

  • Adds a default 16K stdout buffer
  • Default command execution timeout is 3600s (1 hour)
  • Highly improved tests
    • All tests are done for both capture methods
    • Timeout tests are more accurate
    • Added missing encoding tests
    • 2500 rounds of file reading and comparaison are added to detect rare queue read misses

Fixes

  • Use process signals in favor of direct os.kill API to avoid potential race conditions when PID is reused too fast
  • Allow full process subtree killing on Windows & Linux, hence not blocking multiple commands like echo "test" && sleep 100 && echo "done"
    • Windows does not maintain an explicit process subtree, so we runtime walk processes to establish the child processes to kill. Obviously, orphaned processes cannot be killed that way.-