summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Wallace <mikewallace1979@googlemail.com>2014-08-21 16:39:22 +0100
committerJay Doane <jaydoane@apache.org>2021-04-19 00:35:19 -0700
commit8f14524059e359fa47c4983e699f260cc8df1374 (patch)
tree5f4453ae6ddbb5ffbcf15bd1b9418ab7320534fb
parent49bf9e10cbefe0c184531029a8a73dd3e74147ff (diff)
downloadcouchdb-8f14524059e359fa47c4983e699f260cc8df1374.tar.gz
Try to ensure writes to stdout are flushed
This commit adds a promisingly named function to weatherreport_util (flush_stdout/0) which attempts to ensure writes to stdout are flushed. This is called before the script exits in order to avoid an issue where the script output is truncated due to halt being called before stdout is flushed. The implementation of this function is the result of many hours of experimentation and is quite clearly a hack. BugzID: 33697
-rw-r--r--src/weatherreport/src/weatherreport.erl1
-rw-r--r--src/weatherreport/src/weatherreport_util.erl6
2 files changed, 6 insertions, 1 deletions
diff --git a/src/weatherreport/src/weatherreport.erl b/src/weatherreport/src/weatherreport.erl
index 67283178b..86c627376 100644
--- a/src/weatherreport/src/weatherreport.erl
+++ b/src/weatherreport/src/weatherreport.erl
@@ -135,6 +135,7 @@ run(InputChecks) ->
halt(0);
_ ->
lists:foreach(fun weatherreport_check:print/1, SortedMessages),
+ weatherreport_util:flush_stdout(),
halt(1)
end,
halt(1)
diff --git a/src/weatherreport/src/weatherreport_util.erl b/src/weatherreport/src/weatherreport_util.erl
index 37a437aee..a7957922f 100644
--- a/src/weatherreport/src/weatherreport_util.erl
+++ b/src/weatherreport/src/weatherreport_util.erl
@@ -32,7 +32,8 @@
run_command/1,
log/3,log/4,
binary_to_float/1,
- should_log/1]).
+ should_log/1,
+ flush_stdout/0]).
%% @doc Converts a check module name into a short name that can be
%% used to refer to a check on the command line. For example,
@@ -109,3 +110,6 @@ should_log(Level) ->
{ok, L0} -> L0
end,
twig_util:level(AppLevel) >= twig_util:level(Level).
+
+flush_stdout() ->
+ timer:sleep(1000).