English

FAQ: Why does python occasionally hang when calling a method on the geoprocessing dispatch object?

Question

Why does python occasionally hang when calling a method on the geoprocessing dispatch object?

Answer

In many cases this issue is caused by a license conflict. Python assumes that the user has an ArcInfo license and occasionally hangs if this is not the case. This can occur even when the user is only using tools available to their specific license.

To workaround this issue, always verify that Python knows which license being used.Do this by using the 'SetProduct' method on the dispatch object. The code snippet below provides an example.

Code:
import win32com.client
gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1")

gp.SetProduct("ArcView")


To verify which licenses are available use the 'CheckProduct' method on the dispatch object. The code snippet below provides an example.
Code:
import win32com.client
gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1")

print "ArcView license is " + gp.CheckProduct("ArcView")
print "ArcEditor license is " + gp.CheckProduct("ArcEditor")
print "ArcInfo license is " + gp.CheckProduct("ArcInfo")