GP Tool Using Python for ArcGIS Server - Getting Schema Lock with Simulataneous Usage

472
1
Jump to solution
05-23-2014 05:38 PM
IanPeebles
Occasional Contributor III
I have a question.  I have created a python tool that has two input parameters.  These parameters include (input initials) and (input date).  After these parameters are entered in the tool runs and maps building inspections. The output results show a colored point wiwith the matching colored label based on the input initials.  The tool runs fine in desktop and publishes to ArcGIS Server.

In ArcGIS Server, the tool runs well, but when another user runs the tool simultaneously, both user get schema locks in regards to the geocoding service causing the tool to fail.


How can I prevent these schema locks?  The weird thing is that this tool worked before.  I am running ArcGIS Server 10.1 SP1.

This is how my locator is called out within the tool:

AddressesWithBldgNo = r"e:\locators\AddressesWithBldgNo"

scratch workspace is set when I run the tool = e:\outputworkspace

I have a share set up.  Why would I get a schema lock?  How can I use the address locator without getting a schema lock when multiple users are hitting GP service.  Any help will greatly be appreciated.

Ian
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IanPeebles
Occasional Contributor III
I will add that the locator I am using is not coming from SDE.  It is a standalone locator that pull data from SDE.  Could that be the issue?  Here is my code:

# 1. Import arcpy module import arcpy, os, sys, datetime from arcpy import env  # 2. Set geoprocessing environment scratch = arcpy.env.scratchWorkspace arcpy.env.scratchWorkspace = r"E:\geoprocessing\Building\Outputworkspace" arcpy.env.overwriteOutput = True  # 3. Specify Date and Time now = datetime.datetime.now()  # 4. Input Parameters Initials = arcpy.GetParameterAsText(0) InspDate = arcpy.GetParameterAsText(1) if InspDate == "":    InspDate = now.strftime("%m-%d-%y") #This will return today's date. arcpy.AddMessage("Searching for scheduled inspections...") Xpression = """ "INSPECTOR" = \'%s\' AND "SCHEDULED_DATE" = \'%s\' """ % (Initials, InspDate)  # 5. Local variables: sde_sdegis_VCOE_CRWINSPECTIONLOG = r"e:\connections\AGSGIS_TO_SDEGIS_COE.sde\\sde.sdegis.VCOE_CRWINSPECTIONLOG" CRWInspectionLog = "CRWInspectionLog" CRWInspectionLogCopyRows = os.path.join(scratch,CRWInspectionLogCopyRows.dbf) AddressesWithBldgno = r"e:\locators\\AddressesWithBldgNo" ScheduledInspections = os.path.join(ScheduledInspections.shp)  # 6. Make Query Table and Copy Rows if Result is greater than 0 arcpy.AddMessage("Selecting scheduled inspections...")  arcpy.MakeQueryTable_management(sde_sdegis_VCOE_CRWINSPECTIONLOG, CRWInspectionLog, "NO_KEY_FIELD", "", "", Xpression)  result = int(arcpy.GetCount_management(CRWInspectionLog).getOutput(0)) arcpy.AddMessage("Inspections Found: " + str(result)) if result == 0:    arcpy.AddWarning("Process terminated."); sys.exit() else:    arcpy.CopyRows_management(CRWInspectionLog, CRWInspectionLogCopyRows, "")  del CRWInspectionLog  # 7. Geocode Inspections arcpy.AddMessage("Geocoding inspections, please wait...") arcpy.GeocodeAddresses_geocoding(CRWInspectionLogCopyRows, AddressesWithBldgno, Street SITE_ADDR VISIBLE NONE;City <None> VISIBLE NONE, ScheduledInspections, "STATIC") result1 = int(arcpy.GetCount_management(ScheduledInspections).getOutput(0)) arcpy.AddMessage("Inspections Geocoded: " + str(result1)) if result1 < result:    arcpy.AddWarning("Not all inspections were mapped.") else:    arcpy.AddMessage("All inspections mapped.")  # 8. Scheduled Inspections Output arcpy.SetParameterAsText(2, ScheduledInspections)

View solution in original post

0 Kudos
1 Reply
IanPeebles
Occasional Contributor III
I will add that the locator I am using is not coming from SDE.  It is a standalone locator that pull data from SDE.  Could that be the issue?  Here is my code:

# 1. Import arcpy module import arcpy, os, sys, datetime from arcpy import env  # 2. Set geoprocessing environment scratch = arcpy.env.scratchWorkspace arcpy.env.scratchWorkspace = r"E:\geoprocessing\Building\Outputworkspace" arcpy.env.overwriteOutput = True  # 3. Specify Date and Time now = datetime.datetime.now()  # 4. Input Parameters Initials = arcpy.GetParameterAsText(0) InspDate = arcpy.GetParameterAsText(1) if InspDate == "":    InspDate = now.strftime("%m-%d-%y") #This will return today's date. arcpy.AddMessage("Searching for scheduled inspections...") Xpression = """ "INSPECTOR" = \'%s\' AND "SCHEDULED_DATE" = \'%s\' """ % (Initials, InspDate)  # 5. Local variables: sde_sdegis_VCOE_CRWINSPECTIONLOG = r"e:\connections\AGSGIS_TO_SDEGIS_COE.sde\\sde.sdegis.VCOE_CRWINSPECTIONLOG" CRWInspectionLog = "CRWInspectionLog" CRWInspectionLogCopyRows = os.path.join(scratch,CRWInspectionLogCopyRows.dbf) AddressesWithBldgno = r"e:\locators\\AddressesWithBldgNo" ScheduledInspections = os.path.join(ScheduledInspections.shp)  # 6. Make Query Table and Copy Rows if Result is greater than 0 arcpy.AddMessage("Selecting scheduled inspections...")  arcpy.MakeQueryTable_management(sde_sdegis_VCOE_CRWINSPECTIONLOG, CRWInspectionLog, "NO_KEY_FIELD", "", "", Xpression)  result = int(arcpy.GetCount_management(CRWInspectionLog).getOutput(0)) arcpy.AddMessage("Inspections Found: " + str(result)) if result == 0:    arcpy.AddWarning("Process terminated."); sys.exit() else:    arcpy.CopyRows_management(CRWInspectionLog, CRWInspectionLogCopyRows, "")  del CRWInspectionLog  # 7. Geocode Inspections arcpy.AddMessage("Geocoding inspections, please wait...") arcpy.GeocodeAddresses_geocoding(CRWInspectionLogCopyRows, AddressesWithBldgno, Street SITE_ADDR VISIBLE NONE;City <None> VISIBLE NONE, ScheduledInspections, "STATIC") result1 = int(arcpy.GetCount_management(ScheduledInspections).getOutput(0)) arcpy.AddMessage("Inspections Geocoded: " + str(result1)) if result1 < result:    arcpy.AddWarning("Not all inspections were mapped.") else:    arcpy.AddMessage("All inspections mapped.")  # 8. Scheduled Inspections Output arcpy.SetParameterAsText(2, ScheduledInspections)
0 Kudos