Can't acquire a lock on table - but it's not being used by another process.

5353
1
03-22-2012 10:09 AM
Zeke
by
Regular Contributor III
The code below, run as a script added in a toolbox to ArcMap, errors out as shown after a little over a minute. tempBuffer is created, the Case_ field is added, and the case number is added. Actually, only part of the case number was added. the number was ZFY-1234, and only -1234 was added.
Why would 1), this would take over a minute, 2) CalculateField not use the whole value and 3) most importantly, why raise this error? buffer_200 hasn't even had anything done to it yet. Editing the geodb with buffer_200 is started, but nothing's been done with that class prior to Append.
Thanks for any help.

import arcpy
from arcpy import env

env.workspace = r"\\SDE.GDBServerPath\TestCases_Geodatabase.gdb"
case_number = arcpy.GetParameterAsText(0)
buffer_200 = "Buffer"

#-------------------------------------------------------------------------------
# Buffer Processing
#
def CreateBuffer():
    # set buffer parameters
    case = "Cases"
    output ="tempBuffer"
    dist = "200 feet"
    side = "OUTSIDE_ONLY"

    # create temporary buffer
    arcpy.Buffer_analysis(case, output, dist, side)

    # add Case_ field and set it's value to the case number
    arcpy.AddField_management(output, "Case_", "TEXT")
    arcpy.CalculateField_management(output, "Case_", case_number)

    # copy tempBuffer to Buffer feature class
    arcpy.Append_management(output, buffer_200, "NO_TEST")

    # delete tempBuffer
    arcpy.DeleteFeatures_management(output)

def main():
    CreateBuffer()

    arcpy.RefreshTOC
    arcpy.RefreshActiveView
    pass

if __name__ == '__main__':
    main()



Error Message:
Start Time: Thu Mar 22 12:50:21 2012
Running script BufferAndGetOwnerData...
<class 'arcgisscripting.ExecuteError'>: ERROR 999999: Error executing function.
Cannot acquire a lock.
Cannot acquire a lock. [The table Buffer is being written by another process.]
Cannot acquire a lock. [The table Buffer is being written by another process.]
Failed to execute (Append).

Failed to execute (BufferAndGetOwnerData).
Failed at Thu Mar 22 12:51:31 2012 (Elapsed Time: 1 minutes 10 seconds)
Tags (2)
0 Kudos
1 Reply
KimOllivier
Occasional Contributor III
Temporary tables are better written to a local temporary file geodatabase.
Any analysis output written across a network is subject to timeouts, so avoid it and just copy the final result across.
Besides it will be much faster. Even faster if you use" in_memory", a special virtual disk location, for small featureclasses.
Set arcpy.env.overwriteOutput = True so that you can rerun the script without tripping over the first aborted run.
Even then, if you have a crash inside Pythonwin you may need to cleanup and close open files. This was a bit easier with the gp object, with del gp, but now you might have to reopen the GUI, or even log off to cleanup.
0 Kudos