Skip to content

Re-allow creation of progressor in the global environment #99

@HenrikBengtsson

Description

@HenrikBengtsson

In the develop branch progressr (>= 0.7.0), the progressor() function must not be created in the global environment. This was necessary in order to be able to automatically inject an on.exit() call that terminates the progressor when exiting a function, local(), etc. This approach won't work in the global environment. Because of this, progressor() now produce an error if one attempts to call it from the global environment. This helps to protect against an incomplete/interrupted progressor from blocking all future progressors.

However, it might be possible to get around this too. First, I think this is only a problem when the global progress handler is enabled. So, if there is an active progressor in the global environment and we try to create another progressor() from the global environment, then we know that the previous one is no longer of interest and we could terminate that one before creating the new one, e.g.

p1 <- progressor(3)
p1() # incomplete
p1() # still incomplete

p2 <- progressor(4) # here can terminate p1()

EDIT 2021-02-28: The above is now is implemented for the next release (0.8.0).

This leaves the case where we try to use progress updates from another function, e.g.

p1 <- progressor(3)
p1() # incomplete
p1() # still incomplete

slow_sum(1:3)

In this case, the progressor created inside slow_sum() is not created in the global environment. How can we make sure it is ok to terminate p1() in this case? Can we distinguish this case from:

p1 <- progressor(3)
for (kk in 1:2) {
  p1()
  slow_sum(1:3)
}
p1() # complete here

?

I think the answer is: we can't.

I'll leave this issue open for a while to fully digest this idea. Maybe something else will come to me/us

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions