Skip to content

Feature Request: earlier termination as soon as any child fails #8

@ggruenhagen3

Description

@ggruenhagen3

Feature Request
Hi thank you for making this tool! I was wondering if it's possible to have bettermc::mclapply fail as soon as any child process fails, instead of waiting for all child processes to complete in a batch, then failing. I know that mc.fail.early=TRUE does something similar, but I'm requesting something slightly different. In the reproducible example below, I'm using 5 cores, so the code will run in batches of 5 numbers and the number 1 is supposed to fail early. My desired behavior would be for bettermc::mclapply to stop at that point, but instead the current behavior is that it will wait while numbers 2-5 finish before stopping.

Reproducible example

early_fail_fun = function(x) { Sys.sleep(x); print(x); if (x == 1) stop(paste0("Myerror ", x)) }
out = bettermc::mclapply(1:15, early_fail_fun, mc.cores=5, mc.stdout='ignore', mc.allow.fatal=TRUE, mc.allow.error=TRUE, mc.fail.early=TRUE, mc.progress=FALSE)

Version info
R 4.3.1 and bettermc_1.2.2.9000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions