Skip to main content
added 17 characters in body
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completedcompleted;

Calling reset() on the cursorcursor;

The completion of the cursor the cursor;

Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends.

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends.

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed;

Calling reset() on the cursor;

The completion of the cursor;

Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends.

removed incorrect statement about search cursor not locking feature classes
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends. Search cursor does not lock the feature class anyway, so there is no need to worry about the cursor after the comprehension.

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends. Search cursor does not lock the feature class anyway, so there is no need to worry about the cursor after the comprehension.

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends.

tested code and fixed my answer to reflect the results
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

To answerAfter testing your question, it depends on what you're doing after that line of code, and whether you are using update or search(you show both in your question). It will stay in memory until the program endsas gberard pointed out, and if itthere is an update/insertno reference to the cursor it will keep a lockafter the comprehension ends.
Also, there are no locks on your data until the programfeature class after the comprehension ends if you do not delete it. ESRI recommends deleting it Search cursor does not lock the feature class anyway, so there is no need to worry about the cursor after the comprehension.

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

To answer your question, it depends on what you're doing after that line of code, and whether you are using update or search(you show both in your question). It will stay in memory until the program ends, and if it is an update/insert cursor it will keep a lock on your data until the program ends if you do not delete it. ESRI recommends deleting it.

Update and insert cursors cannot be created for a table or feature class if an exclusive lock exists for that dataset. The UpdateCursor or InsertCursor functions fail because of an exclusive lock on the dataset. If these functions successfully create a cursor, they apply an exclusive lock on the dataset so that two scripts cannot create an update or insert cursor on the same dataset.

In Python, the lock persists until the cursor is released. Otherwise, all other applications or scripts could be unnecessarily prevented from accessing a dataset. A cursor can released by one of the following:

Including the cursor inside a with statement, which will guarantee the release of locks regardless of whether or not the cursor is successfully completed Calling reset() on the cursor The completion of the cursor Explicitly deleting the cursor using Python's del statement

Locking with arcpy.da cursors is pretty much the same as locking with the original arcpy cursors.

After testing your code, and as gberard pointed out, there is no reference to the cursor after the comprehension ends.
Also, there are no locks on the feature class after the comprehension ends. Search cursor does not lock the feature class anyway, so there is no need to worry about the cursor after the comprehension.

found updated info for da cursors (basically the same as locking with the original cursors)
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41
Loading
Source Link
jbalk
  • 7.6k
  • 1
  • 18
  • 41
Loading