bjebn

multiprocessing Attribute Error

Discussion created by bjebn on Dec 7, 2011
Latest reply on Feb 2, 2012 by taylor65
Has anyone tried to implement multiprocessing into their scripts? I've attempted to use the suggestion from http://blogs.esri.com/Dev/blogs/geoprocessing/archive/2011/08/29/Multiprocessing.aspx with raster processes but with no success i.e.


import os, multiprocessing, arcpy 

def project(raster):
        arcpy.ProjectRaster_management(raster...) 

def main():
        workspace = r'c:\somepath'
        arcpy.env.workspace = workspace
        fcs = arcpy.ListRasters('*')
        fc_list = [os.path.join(workspace, fc) for fc in fcs]
        pool = multiprocessing.Pool()
        pool.map(project, fc_list)
        pool.close()
        pool.join()

if __name__ == '__main__':    
        main()


However in the command line this gives me the error


File "C:\Python26\ArcGIS10.0\lib\multiprocessing\process.py", line 232, in _bootstrap
     self.run()
File "C:\Python26\ArcGIS10.0\lib\multiprocessing\process.py", line 88, in run
     self._target(*self._args, **self._kwargs)
File "C:\Python26\ArcGIS10.0\lib\multiprocessing\pool.py", line 57, in worker
     task = get() File "C:\Python26\ArcGIS10.0\lib\multiprocessing\queues.py", line 352, in get return recv()
AttributeError: 'module' object has no attribute'project'


I've been trying to work around the problem with parallel python without success and I cannot figure out how my code differs from the original.

Bjebn

Outcomes