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

Do not unload namespaces in package cleanup #167

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Do not unload namespaces in package cleanup #167

merged 1 commit into from
Nov 11, 2024

Conversation

shikokuchuo
Copy link
Owner

Fixes #166.

@wlandau this is my proposed fix. Please let me know if you can think of any corner cases - I can't think how this change would be problematic. Thanks!

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.71%. Comparing base (92afc17) to head (d44736d).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #167   +/-   ##
=======================================
  Coverage   99.71%   99.71%           
=======================================
  Files           9        9           
  Lines         692      692           
=======================================
  Hits          690      690           
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shikokuchuo
Copy link
Owner Author

Note that this would then be consistent with namespaces that are not attached in the first place:

library(mirai)
daemons(1)
#> [1] 1
mirai(loadedNamespaces())[]
#>  [1] "compiler"  "graphics"  "utils"     "grDevices" "stats"     "datasets" 
#>  [7] "methods"   "mirai"     "base"      "nanonext"
mirai(data.table::data.table())[]
#> data frame with 0 columns and 0 rows
mirai(loadedNamespaces())[]
#>  [1] "compiler"   "graphics"   "utils"      "grDevices"  "stats"     
#>  [6] "datasets"   "data.table" "methods"    "mirai"      "base"      
#> [11] "nanonext"
daemons(0)
#> [1] 0

Created on 2024-11-11 with reprex v2.1.1

@shikokuchuo shikokuchuo changed the title Do not unload shared libraries in package cleanup Do not unload namespaces in package cleanup Nov 11, 2024
@wlandau
Copy link

wlandau commented Nov 11, 2024

If this solves #166, then it seems reasonable.

I'm not sure which conditions can reproduce the original data.table-related issue in #166, replicate(100, {library(data.table); detach(name = "package:data.table", unload = TRUE, character.only = TRUE)}) seems to work fine on my end.

@shikokuchuo
Copy link
Owner Author

The following reliably crashes for me after a few iterations:

for (i in 1:100) {
  library(data.table); data.table(); detach(name = "package:data.table", unload = TRUE, character.only = TRUE)
}

@shikokuchuo shikokuchuo merged commit 3477ac7 into main Nov 11, 2024
19 of 20 checks passed
@shikokuchuo shikokuchuo deleted the cleanup branch November 11, 2024 20:58
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

Successfully merging this pull request may close these issues.

mirai_map daemons fail after 13 jobs when creating data.tables
3 participants