SLIDER-584 flush output after every line and at the end of the run
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/2826027e Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/2826027e Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/2826027e Branch: refs/heads/feature/SLIDER-531-registry-enhancements Commit: 2826027e260b9d278769eb22a87d37238eb4419a Parents: 035dbe7 Author: Steve Loughran <[email protected]> Authored: Thu Oct 30 13:18:03 2014 +0000 Committer: Steve Loughran <[email protected]> Committed: Thu Oct 30 13:18:03 2014 +0000 ---------------------------------------------------------------------- slider-assembly/src/main/scripts/slider.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2826027e/slider-assembly/src/main/scripts/slider.py ---------------------------------------------------------------------- diff --git a/slider-assembly/src/main/scripts/slider.py b/slider-assembly/src/main/scripts/slider.py index 38ff68d..e67a6ff 100644 --- a/slider-assembly/src/main/scripts/slider.py +++ b/slider-assembly/src/main/scripts/slider.py @@ -122,6 +122,17 @@ def out(toStdErr, text) : else: sys.stdout.write(text) +def flush(toStdErr) : + """ + Flush the output stream + :param toStdErr: flag set if stderr is to be the dest + :return: + """ + if toStdErr: + sys.stderr.flush() + else: + sys.stdout.flush() + def read(pipe, line): """ read a char, append to the listing if there is a char that is not \n @@ -147,6 +158,7 @@ def print_output(name, src, toStdErr): Relay the output stream to stdout line by line :param name: :param src: source stream + :param toStdErr: flag set if stderr is to be the dest :return: """ @@ -156,13 +168,16 @@ def print_output(name, src, toStdErr): (line, done) = read(src, line) if done: out(toStdErr, line + "\n") + flush(toStdErr) line = "" # closedown: read remainder of stream c = src.read(1) while c!="" : out(toStdErr, c) + if c == "\n": + flush(toStdErr) c = src.read(1) - + flush(toStdErr) src.close()
