From simon.urbanek at r-project.org  Thu May 22 06:05:07 2014
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 22 May 2014 00:05:07 -0400
Subject: [Rd] issue with parallel package
In-Reply-To: <CABFfbXua6VU0AaEyZL2NCdNWnFLJyUpQrfxdUQkK4ZnLHyjFtA@mail.gmail.com>
References: <mailman.25.1400666408.17616.r-devel@r-project.org>
	<20140521171729.GA14219@leim.stat-math.wu.ac.at>
	<CABFfbXua6VU0AaEyZL2NCdNWnFLJyUpQrfxdUQkK4ZnLHyjFtA@mail.gmail.com>
Message-ID: <ABE91EA9-421E-4A0F-A2C9-96FB78FB3BF4@r-project.org>


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



[Rd] issue with parallel package
Simon Urbanek