From pdalgd at gmail.com  Wed Feb  6 12:06:21 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Wed, 6 Feb 2013 12:06:21 +0100
Subject: [Rd] best practice for packages using mclapply to avoid tcltk
In-Reply-To: <20754.8811.443519.383545@stat.math.ethz.ch>
References: <CAErODj_1hg8+x5SvOmoL8V9RMNgMAN_fXGBLcsJhgnH_k2jOgw@mail.gmail.com>
	<F667EFC5-41D0-4F56-AE80-FCBDBE65F46E@r-project.org>
	<CAErODj9qtvB=s0zphXywin5ZpXozVKdj0qeRvAp9cyFy3O8coA@mail.gmail.com>
	<20754.8811.443519.383545@stat.math.ethz.ch>
Message-ID: <93EFFCAA-BC1A-4218-B92D-12EE55B3BA2B@gmail.com>


On Feb 6, 2013, at 10:29 , Martin Maechler wrote:

>>>>>> "PJ" == Paul Johnson <pauljohn32 at gmail.com>
>>>>>>    on Tue, 5 Feb 2013 22:25:01 -0600 writes:
> 
>> On Sun, Feb 3, 2013 at 1:34 PM, Simon Urbanek
>> <simon.urbanek at r-project.org> wrote:
>>> As Peter pointed out earlier, this is better addressed by
>>> disabling the Tcl/Tk event loop in forked processes.
>>> 
>> Dear Simon:
> 
>> I don't understand.  Can you please try to say it again?
> 
>> I find Peter's comment (on Jan 3, 2013, thread title:
>> weird bug with parallel, RSQlite and tcltk):
> 
>> "More likely, the wisdom of calling R_ProcessEvents and
>> R_PolledEvents in parallel processes should be
>> questioned. I tend to think that they should both be
>> disabled completely conditionally on R_isForkedChild.
>> At least in the Tk loop, some of the events are
>> generated as responses to specific queries, and having
>> one process ask for something and another one handling
>> the reply, leaving the first one waiting indefinitely,
>> is just Not Right."
> 
>> That suggested to me the problem is in R itself, or the
>> tcltk package
> 
> Well, it should have suggested that the problem should be
> addressed "in R itself"?

Exactly. Except that I worried about possible side effects enough that I didn't go in and fix things myself (I am not completely up to speed on the internals of the parallel stuff). So Brian did it.

> and it now has been:
> 
> The NEWS  for R 2.15.2 patched (and hence "R devel" and all
>    	      	       	       	future versions of R)

In principle, that is a non sequitur, but in this case, the change was ported FROM R-devel (r61839).

(As a general matter, it is possible for R-devel to diverge from R-patched to such an extent that modifications to one don't make sense for the other. This usually doesn't happen, though.)

> now contain
> 
>      The Tcl/Tk event loop is inhibited in a forked child (as in e.g.
>      mclapply().

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] best practice for packages using mclapply to avoid tcltk
peter dalgaard