[Rd] issue with parallel package

Simon Urbanek simon.urbanek at r-project.org
Thu May 22 06:05:07 CEST 2014


On May 21, 2014, at 1:47 PM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu> wrote:

> On Wed, May 21, 2014 at 10:17 AM, Josef Leydold <josef.leydold at wu.ac.at> wrote:
> I ran into an issue with the parallel package in R-3.1.0.
> 
> I have been experiencing a very similar issue within the RAppArmor package. Here is a smaller example:
> 
> library(parallel)
> for (n in 1:5) {
>   p <- mcparallel(sqrt(n))
>   #Sys.sleep(0.01)
>   res <- mccollect(p, wait=FALSE, timeout=1000)
>   mccollect(p)
>   if (is.null(res)) cat(n,"  NULL!\n")
> }
> 
> If we run this, mccollect returns a lot of NULL values. However, after uncommenting the sys.sleep, the problem disappears. Seems like some sort of race condition.
> 

It's not a race condition - it behaves as expected - the mccollect with wait=FALSE will return NULL since there is no reason to expect the result to be available at that point. If you add the delay, then it's more likely that the result will be available by then.

Cheers,
Simon



More information about the R-devel mailing list