Skip to content

Commit

Permalink
Merge pull request #1281 from gnu-octave/cap_wait_time
Browse files Browse the repository at this point in the history
Cap the exponential growth in waitdelta at 1
  • Loading branch information
cbm755 authored Jan 2, 2024
2 parents 43e25cf + ddb52bf commit 4067b40
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions inst/private/readblock.m
Original file line number Diff line number Diff line change
@@ -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.
%%
Expand Down Expand Up @@ -33,6 +33,8 @@
done = false;
started = false;
nwaits = 0;
lastdot = 0;
skip = 0;
dispw = false;
start = time();

Expand All @@ -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 ()))
Expand All @@ -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 ()))
Expand Down

0 comments on commit 4067b40

Please sign in to comment.