From ddb52bf608fc8de4c3b886e1ce52408b1796feb9 Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Mon, 1 Jan 2024 23:16:57 -0800 Subject: [PATCH] Cap the exponential growth in waitdelta at 1 Fixes #1255. Probably the distribution during the initial 8 seconds could be tweaked, but I left it as-is. --- inst/private/readblock.m | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/inst/private/readblock.m b/inst/private/readblock.m index 286375837..c148a113a 100644 --- a/inst/private/readblock.m +++ b/inst/private/readblock.m @@ -1,4 +1,4 @@ -%% Copyright (C) 2014-2015 Colin B. Macdonald +%% Copyright (C) 2014-2015, 2024 Colin B. Macdonald %% %% This file is part of OctSymPy. %% @@ -33,6 +33,8 @@ done = false; started = false; nwaits = 0; + lastdot = 0; + skip = 0; dispw = false; start = time(); @@ -59,14 +61,22 @@ end elseif (errno() == EAGAIN || errno() == EINVAL) - waitdelta = exp(nwaits/10)/1e4; + % with these coefficients, we check about 90 times before the display + % starts at 8 seconds; at that time the waitdelta is approx 1 second. + % We cap the waiting at 1 second (Issue #1255). + waitdelta = min(1, exp(nwaits/10)/1e4); if (time() - start <= wait_disp_thres) - %fprintf(stdout, 'W'); % debugging, in general do nothing + % no-op elseif (~dispw) fprintf(stdout, 'Waiting...') dispw = true; else - fprintf(stdout, '.') + if nwaits - skip >= lastdot + fprintf(stdout, '.') + lastdot = nwaits; + % Don't draw every second; increase the number of seconds to skip + skip = skip + 1; + end end fclear (fout); %if (ispc () && (~isunix ())) @@ -75,14 +85,18 @@ pause (waitdelta); nwaits = nwaits + 1; elseif (errno() == 0) - waitdelta = exp(nwaits/10)/1e4; + waitdelta = min(1, exp(nwaits/10)/1e4); if (time() - start <= wait_disp_thres) - %fprintf(stdout, 'W'); % debugging, in general do nothing + % no-op elseif (~dispw) fprintf(stdout, '[usually something wrong if you see stars] Waiting***') dispw = true; else - fprintf(stdout, '*') + if nwaits - skip >= lastdot + fprintf(stdout, '*') + lastdot = nwaits; + skip = skip + 1; + end end fclear (fout); %if (ispc () && (~isunix ()))