I have a simple script to test multiprocessing with arcpy, but the script hang indefinitely. The problem is with the import arcpy statement that seems to be a problem in the child processes. Other multiprocessing script without import arcpy are working correctly

import arcpy
import multiprocessing

import os, sys
multiprocessing.set_executable(os.path.join(sys.exec_prefix, 'python.exe'))

def testExists(data):
    print data
    return arcpy.Exists("foo.gdb")

if __name__ == '__main__':
    data = ["foo.gdb", "bar.gdb"]
    pool = multiprocessing.Pool(2)
    result_arrays = pool.map(testExists, data)
    print result_arrays

Any idea what can cause the problem?

  • 1
    FYI I tested on my end and it worked. – Emil Brundage Jul 24 at 16:03
  • Could it be a license problem? – Below the Radar Jul 24 at 16:32
  • @EmilBrundage have you tested from a cmd prompt or from a toolbox? – Below the Radar Jul 24 at 16:33
  • I tested from IDLE – Emil Brundage Jul 24 at 16:34
  • @BelowtheRadar Are you sure it's hanging indefinitely and not hiding an error somehow? When I run from IDLE it works fine, but when I run it from a toolbox it first appears to be hanging and then I see there is an error in the toolbox output PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed. See stackoverflow.com/a/8805244/5754917 – Midavalo Aug 2 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.