-
Notifications
You must be signed in to change notification settings - Fork 40
Description
ReprEx:
try(rm(pb0));
pb0 <- progress_bar$new(format = " got :current rows at :tick_rate/sec, total time :elapsed, total rows :total", clear = FALSE);
for(ii in 1:10) {Sys.sleep(1/10);pb0$tick(1000)};
pb0$terminate();
Expected behavior:
# got 10000 rows at 10989/sec, total time 1s
Observed behavior:
# Error in pb_tick(self, private, len, tokens) : !self$finished is not TRUE
Workaround:
try(rm(pb0));
pb0 <- progress_bar$new(format = " got :current rows at :tick_rate/sec, total time :elapsed", clear = FALSE, total=NA);
for(ii in 1:10) {Sys.sleep(1/10);pb0$tick(1000)};
pb0$terminate();
Both changes are necessary-- removing any reference to :total when the total is unknown and adding an explicit total=NA.
I think that when the tick-count exceeds the default value for total (100), this error is triggered unless total is explicitly set to NA.
Yes, it's on me for failing to register that :total is redundant with :current when the total is unknown. But I see a number of downstream unresolved problems featuring this error over the years:
mikajoh/stmprinter#2
r-dbi/bigrquery#269
https://stackoverflow.com/questions/52655172/r-cannot-import-data-through-bigrquery-package-selffinished-is-not-true
So perhaps there would be a benefit to making this more obvious. Some possibilities:
- Explicitly saying in the help file that the tick counts must not be permitted to exceed the expected total
- Catching and handling that case-- e.g. by letting the progress bar to seem to go beyond its expected limit as some apps do.
- Replacing the current
!self$finished is not TRUEmessage with a more informative one.
Until then, hopefully this post will help whomever else has this problem and is persistent enough to follow it here. :-)