lgtateos

Python WITH statement does not release da cursor schema locks

Discussion created by lgtateos on Mar 4, 2013
Latest reply on Jan 27, 2015 by bixb0012
According to this page
http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001q000000

The Python WITH statement should release all data access cursor locks.  It doesn't release schema locks.  *sr.LOCK files persist.  For example, foo remains locked after the following code is run:

import arcpy
with arcpy.da.SearchCursor( 'C:/Temp/foo.shp' , [ "*" ] ) as cursor:
    for row in cursor:
        print row[0]


My questions are...
1) Is this by design?  It kind of makes sense,  since one can go on and use the cursor some more even after the with block is exited.  Seems like it would be bad to edit the schema while you've got a cursor pointing to that file.

2) if this is not by design, is someone going to fix it soon?  If so, when?

3) If this is by design, why use the WITH statement in all the examples?  Sure, it gets rid of the read/write locks, but it doesn't remove all locks, so it messes up your workflow anyway.

4) If this is by design, shouldn't the documentation be modified?

Thanks for the help.

Outcomes