Hello all
I am trying to run multiprocessing python from Pro toolbox.
The simple code below works in IDLE with no problem (in PyScripter too).
It uses the print() and not AddMessage and the output comes with main2 since the child processes does not see the main window.
Trying to run it in Pro toolbox gives unclear error message.
Trying to run it from notebook open many Pro's (do not try this at home with a number bigger then 6 !!)
There are a few posts and blogs that say it should be possible https://www.esri.com/arcgis-blog/products/arcgis-desktop/analytics/python-multiprocessing-approaches-and-considerations/?rmedium=blogs_esri_com&rsource=/esri/arcgis/2011/08/29/multiprocessing/ but nothin new.
anybody is using this?
Each function (my_body) is complitly seperated from the others.
Thanks
import multiprocessing
import arcpy
def my_body (parm):
arcpy.AddMessage("func " + str(parm))
print("func2 " + str(parm))
return(parm)
if __name__ == '__main__':
listNumbers = [(1,1),(2,2),(3,3),(4,4)]
p = multiprocessing.Pool(6)
res = p.map(my_body, listNumbers)
arcpy.AddMessage("main " + str(res))
print("main2 " + str(res))
p.close()
p.join()