From 723e3545100c3be18dc9d171378e8508d1199091 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 14 Feb 2024 07:27:01 -0600 Subject: [PATCH] Document that you must always close the pool Fixes #170 --- R/pool-methods.R | 5 +++++ man/Pool-class.Rd | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/R/pool-methods.R b/R/pool-methods.R index bc88c22..bcc34a5 100644 --- a/R/pool-methods.R +++ b/R/pool-methods.R @@ -6,6 +6,11 @@ #' little computational cost. The pool should be created only once #' and closed when it is no longer needed, to prevent leaks. #' +#' Every usage of `poolCreate()` should always be paired with a call to +#' `poolClose()` to avoid "leaking" resources. In shiny app, you should +#' create the pool outside of the server function and close it on stop, +#' i.e. `onStop(function() pool::poolClose(pool))`. +#' #' See [dbPool()] for an example of object pooling applied to DBI database #' connections. #' diff --git a/man/Pool-class.Rd b/man/Pool-class.Rd index 5899c02..4eddda7 100644 --- a/man/Pool-class.Rd +++ b/man/Pool-class.Rd @@ -49,6 +49,11 @@ from the pool and released back to it at will, with very little computational cost. The pool should be created only once and closed when it is no longer needed, to prevent leaks. +Every usage of \code{poolCreate()} should always be paired with a call to +\code{poolClose()} to avoid "leaking" resources. In shiny app, you should +create the pool outside of the server function and close it on stop, +i.e. \code{onStop(function() pool::poolClose(pool))}. + See \code{\link[=dbPool]{dbPool()}} for an example of object pooling applied to DBI database connections. }