RStudio stuck when using reticulate to call multiprocess script in python

Hello,

I am trying to use reticulate package to call python script named 'multiprocess_test.py' which the content is like below:

from multiprocess import Pool

def f(x):
    return x * x


p = Pool(4)

def test():
    print(p.map_async(f, [1, 2, 3, 4, 5]).get())
    return 0

# test()

When I tested this python script, it was ok to get the result in python IDE spyder. But when I tried to do the same thing through RStudio, it always stuck there.

Below is the code in RStudio:

setwd('C:/Users/dk/')
library(reticulate)
condaEnvName <- 'myEnv'
reticulate::use_condaenv(condaEnvName, required = TRUE)
reticulate::source_python('./multiprocess_test.py')

# Test the python function in RStudio. It stuck here and seems always running, I must terminate R to stop
test()

Can you help me to figure out about this issue. Or in general, how can I call python script in the specified the environment, where the python script was using 'multiprocess' in parallel like above? Previously, all things are ok when the python script did not include the multiprocess, at that time I can successfully call the python script using reticulate::source_python() and after this I just called corresponding functions in python.

Thank you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.