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

curl handles in handle_pool become dead in package finalizer #674

Closed
okhoma opened this issue Oct 24, 2020 · 1 comment
Closed

curl handles in handle_pool become dead in package finalizer #674

okhoma opened this issue Oct 24, 2020 · 1 comment

Comments

@okhoma
Copy link

okhoma commented Oct 24, 2020

When same urls are requested in some package functions and in package finalizer, curl handles cached in handle_pool become "dead", because curl handle finalizers are run before package finalizer.

Here is a reprex (put in a package)

test <- function() httr::GET("https://www.google.com")
.onLoad <- function(x, y) {
  reg.finalizer(environment(sys.function()), function(env) test(), TRUE)
  test()
}

Right now I just call httr::handle_reset() for each URL used in the finalizer, but I would prefer to have a more generic approach, because these URLs are called by some other packages internals and they may change in the future, breaking my package.

I think one of the following options could work:

  • have an option to not maintain handle_pool at all
  • have a function handle_pool_reset() to clear the whole pool
  • update httr::handle_find() to check if the handle is not dead before returning it (will require new curl::handle_is_dead() function)
  • update httr::handle_find() to add its own finalizer that would remove the url from the pool before the handle is cleared by curl

I can submit a pool request :), just not sure which approach would be preferred.

Thanks,
Oleh Khoma

@hadley
Copy link
Member

hadley commented Oct 31, 2023

httr has been superseded in favour of httr2, so is no longer under active development. If this problem is still important to you in httr2, I'd suggest filing an issue offer there 😄. Thanks for using httr!

@hadley hadley closed this as completed Oct 31, 2023
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

2 participants