Is it safe to call RPy functions in a multiprocessing environment and are there any multiprocessing issues regarding RPy that one should be aware of?
A simple example might be the following:
from multiprocessing import Pool
from rpy import *
def f(x):
return r.mean(x)
if __name__ == '__main__':
p = Pool(5)
print sum(p.map(f, [range(1, 1000000), range(2, 2000000), range(3, 3000000)]))
Seeing that multiprocessing spawns new python instance for each worker instance in the pool and they share no common resources — including instances of the R process, — chances are it is thread-safe. Best way is to test it and see.