-
Hi Golem Devs, Since a I'm sure y'all have encountered this issue but I didn't see it mentioned in the Engineering Shiny chapter or in the issues thus far so I thought I would ask how you handle it? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hey, So the trick is to assign your internal function inside an environment or a list, so that this list can be passed to the parallel session. The parallel session is indeed not aware of your package if it's not installed, but you can "transport" objects to the parallel session. See https://github.com/ColinFay/golemexamples/blob/master/golemfuture/R/app_server.R#L29 for an example where we transport https://github.com/ColinFay/golemexamples/blob/master/golemfuture/R/fct_helpers.R#L8 to the parallel session. Hope this helps, |
Beta Was this translation helpful? Give feedback.
-
Hi Colin, For context, we have an R6 class that handles the database connection and all the methods that use the database. We're trying to offload these db queries to This was complicated by the fact that the function we needed in the future background process was a function defined in the golem app namespace and that instantiates a database connection (it will go stale if passed between environments).
error:
error:
error:
Works, provided that We found the
Hope this is helpful! If any of it doesn't make sense feel free to @ me |
Beta Was this translation helpful? Give feedback.
-
Hmm, Two more workarounds that don't work:
Ugh, this limitation makes for some seriously heavy revision to make code asynchronous. It almost makes it entirely not worth it. |
Beta Was this translation helpful? Give feedback.
Hi Colin,
This proved to be a much trickier task than anticipated, and after numerous attempts we finally got it to work. This might be something worth adding to the
Optimizing {shiny}
documentation as I feel like there's definitely others that probably get tripped up on a similar use case.For context, we have an R6 class that handles the database connection and all the methods that use the database. We're trying to offload these db queries to
future
.This was complicated by the fact that the function we needed in the future background process was a function defined in the golem app namespace and that instantiates a database connection (it will go stale if passed between environments).
T…