python parallel processing in arcgispro

Multi-process processing cannot be used in arcgis pro, which will cause multiple pro to be opened, resulting in errors.

So you have to use threads for processing

Copy example

from multiprocessing.dummy import Pool as ThreadPool
import multiprocessing, time
 
 
def mainfunc(num):
    starttime = time.time()
    s = 1
    for i in range(1, num):
        s *= i
 
    endtime = time.time()
    return "耗时:{0}".format(endtime-starttime)
 
 
if __name__ == '__main__':
    pool = ThreadPool(multiprocessing.cpu_count())
    listdata = [200000, 200000, 200000, 200000, 200000, 200000, 200000, 200000]
    result = pool.map(mainfunc, listdata)
    pool.close()
    pool.join()
    print(result)

If you want to use multi-process processing, you must set it as follows

question

When assigning the notebook (python editor) to the toolbox, it will not run.

Solution: Check whether the parameters given by the function are consistent and ensure that all the parameters given can be used.

references

How to simply distinguish between Python multi-process and multi-thread_arcpy blocking-CSDN Blog

Python programming based on ArcGIS 11. Use multi-process optimization to generate point data in batches based on Excel tables and crop them in batches - Zhihu

Guess you like

Origin blog.csdn.net/qq_39397927/article/details/134952343