Running a script in process

If your script tool runs a Python script, you should check the Run Python script in process option to run the script in-process, as shown below. This option only applies to Python scripts.

Add Script Wizard panel 2

Only scripts that import ArcPy as shown below—or create the geoprocessor object using arcgisscripting.create()—can be run in-process.

import arcpy

Scripts that use dispatch, as shown below, will not be run in-process, even if Run Python script in process is checked.

import win32com.client
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

The Run Python script in process option became available in ArcGIS 9.3. Prior to 9.3, Python scripts were run out-of-process. Running out-of-process requires that ArcGIS start another process (think of this as starting another program), which takes time. When running out-of-process, there are also performance issues with message communication between the two processes. Starting at version 9.3, Python is incorporated into ArcGIS so that scripts can be run in-process, removing all startup time and messaging overhead.

Running in-process requires that all modules loaded with the Python import directive have the necessary logic to enable them to run in-process. All standard Python libraries, such as os, string, and time, have the necessary logic. However, non standard modules obtained from third parties may not have the necessary logic to run in-process. If you are experiencing unexplainable problems when your script runs, try unchecking the in-process option and running your script again. If the problem goes away when running out-of-process, then there is most likely an issue with one of the modules you imported. In this case, leave the option unchecked.