Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HenrikBengtsson opened this issue Dec 6, 2020 · 0 comments
Open

Comments

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Dec 6, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant