Skip to content
Prev 262455 / 398502 Next

running R commands asynchronously

Good points, I was going to include something along the lines of don't change any data in the console that is involved in the asynchronous process, but figured Richard was smart enough to not do something like that.  But your points add to that and make it clear for others who read this that don't have the experience to know better.

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Friday, June 10, 2011 11:36 PM
To: Greg Snow
Cc: Richard M. Heiberger; r-help
Subject: Re: [R] running R commands asynchronously
On Fri, 10 Jun 2011, Greg Snow wrote:

            
That is really not advised.  R is not designed to run asynchronous R 
commands and is not protected against quite a lot of things which can 
happen if you try that (many low-level routines are not re-entrant, 
for example).  Allowing callbacks to either run simple things (as 
happens from e.g. the GUI menus) whilst a task is running, or to do 
almost all the running (as happens with a menu system built in Tk) is 
fairly safe just because only one task is likely to run at a time.

For over a decade Duncan TL has promised a facility to run tasks in 
parallel in R (as I recall the estimate at DSC 2001 was 12 months).

So the only safe way at present (and the foreseeable future) is to run 
separate processes.  Packages snow and multicore provide means to do 
that (and to wait for and collect results): in the case of multicore 
the parallel tasks work on a copy of the current session and so you do 
come close to the appearance of running aysnchronous tasks.  (By 
choosing to use Windows you exclude yourself from multicore.)