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

Check for leaving behind opened connections, sinks, graphical devices #746

Open
HenrikBengtsson opened this issue Nov 2, 2024 · 0 comments
Milestone

Comments

@HenrikBengtsson
Copy link
Collaborator

Issue

For example,

f <- future({
  db <- DBI::dbConnect(RSQLite::SQLite(), "db.sqlite", extended_types = TRUE)
  42L
})

will leave behind an open connection on the worker.

Task

We could check for this and produce an informative warning when there's a connection left behind. This can be done by looking at getAllConnections() before and after evaluating the future and report on details from showConnections().

Minimal reproducible example

> ## Before
> cons0 <- getAllConnections()
> cons0
[1] 0 1 2

> f <- future({ con <- textConnection("abc"); as.integer(con) })

> ## During ...
> cons1 <- getAllConnections()
> cons1
[1] 0 1 2 4

> id <- value(f)
> id
[1] 4

> ## After ...
> cons2 <- getAllConnections()
> cons2
[1] 0 1 2 4
> setdiff(cons2, cons1)
[1] 4
@HenrikBengtsson HenrikBengtsson added this to the Next release milestone Nov 2, 2024
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