You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2023/04/14 19:28:27 UTC

[GitHub] [arrow] paleolimbot commented on a diff in pull request #33858: GH-15054: [C++] Change s3 finalization to happen after arrow threads finished, add pyarrow exit hook

paleolimbot commented on code in PR #33858:
URL: https://github.com/apache/arrow/pull/33858#discussion_r1167209940


##########
r/R/arrow-package.R:
##########
@@ -147,6 +153,12 @@ supported_dplyr_methods <- list(
   # Register extension types that we use internally
   reregister_extension_type(vctrs_extension_type(vctrs::unspecified()))
 
+  # Registers a callback to run at session exit
+  .onLoad <- function(libname, pkgname) {
+    print(parent.env(environment()))
+    reg.finalizer(parent.env(environment()), finalize_s3, onexit=TRUE)
+  }
+

Review Comment:
   I know you asked about this earlier and found `.onUnload()`...just putting a note here in case this gets forgotten about.
   
   If `.onUnload()` isn't working you can create your own environment an register a finalizer on that:
   
   ```r
   s3_finalizer <- new.env(parent = emptyenv())
   
   .onLoad <- function(...) {
     # ...
     reg.finalizer(s3_finalizer, finalize_s3, onexit=TRUE)
   }
   ```
   
   You probably shouldn't register a finalizer on the package namespace because somebody else might have done that (maybe even R).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org