I am seeking help with handling downloadhandler asynchronously in a shiny app. I have posted this question on stack overflow though I haven't gotten any answers yet.
Below is a reprex of how my downloadhandler looks like:
I would love to have the app available for other users when one user clicks the download button. I've tried wrapping the write.csv inside a future function and setting `and while this does not throw an error, the app is not available for other users during the download.
I've also tried wrapping the entire downloadHandler function inside the future function, but I get the error:
Error in .subset2(x, "impl")$defineOutput(name, value, label) :
Unexpected MulticoreFuture output for DownloadUnexpected MultiprocessFuture output for DownloadUnexpected Future output for DownloadUnexpected environment output for Download
How can I handle the entire downloadHandler asyncronously? I am using the open source version of shiny server.
Wrapping write.csv in a future should work (probably the two write.csv lines and the zip line should all be in a single future). Are you sure you're using Shiny v1.2.0?
Thanks @jcheng for pointing me in the right direction. I am on Shiny v1.2.0. However, in my actual code, I was erroneously trying to read reactive values from within a future.
After fixing this through reading the reactive values first and wrapping the write.csv and zip lines inside a single future, the app works alright, but the download doesn't happen until the second user's process is completed. (i.e., if the download normally takes 5 seconds but a second user requests a process that takes 20 seconds, the download is served after 20 seconds). I would have expected that the download is served within normal time. I am using plan(multiprocess) though I have also tried with plan(multisession). I am on linux.