Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Running coro in R scripts #34

@Fabrice-Clement

Description

@Fabrice-Clement

Hello,

Nice R package that I love to use now !

I would like to use coro in a R script, but when I run the example https://coro.r-lib.org/reference/async.html with Rscript, it ends immediatly.

How can I wait the termination of the promise before R exits ?

The only ( and dirty ) solution I found is :

# mycoroScript.R
# see https://coro.r-lib.org/reference/async.html
promises::promise_all( async_count_down(5), async_count_up(5) ) %>%  then( function(value) {
        writeLines("q( status = 0)", f <- file("/tmp/fifo", raw=T) ); close(f)
}

To run it from bash :
$ ( mkfifo /tmp/fifo; cat mycoroScript.R; cat /tmp/fifo)  | R --interactive --no-save

Thanks for your advice !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions