<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Clarifying when cursor locks are released in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38641#M3030</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah, I just entered it last week, so it usually takes a few days.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Mar 2013 15:43:08 GMT</pubDate>
    <dc:creator>LucasDanzinger</dc:creator>
    <dc:date>2013-03-12T15:43:08Z</dc:date>
    <item>
      <title>Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38637#M3026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does the following line of code "release" the cursor?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#Note: rdsmall_lyr has a single selected feature rdsmall_values = sorted(arcpy.da.SearchCursor(rdsmall_lyr, ["UA", "FAID_S", "CTCODE", "RTNUMBER", "AOTCLASS"]))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;The help pages state that a cursor can be released by the completion of the cursor (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001q000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001q000000&lt;/A&gt;&lt;SPAN&gt;), but I'm not very confident in my understanding of an implicit release.&amp;nbsp; Any insight would be greatly appreciated!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I do have an alternative approach that I'm confident tidies up after itself (below), but am hoping I can get away with the simpler code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;with arcpy.da.SearchCursor(rdsmall_lyr, ["UA", "FAID_S", "CTCODE", "RTNUMBER", "AOTCLASS"]) as road_cur: &amp;nbsp;&amp;nbsp;&amp;nbsp; rdsmall_values = sorted(road_cur)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 13:53:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38637#M3026</guid>
      <dc:creator>KerryAlley</dc:creator>
      <dc:date>2013-03-12T13:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38638#M3027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The '__enter__' and '__exit__' methods were added to the da cursors to help with locking issues. They are most easily and explicitly accessed via the with statement which is the preferred method of opening and closing da cursors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That being said, your code should be releasing the locks immediately after it runs, assuming there were no other errors.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 15:17:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38638#M3027</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-03-12T15:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38639#M3028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The second statement should release the locks automatically, but there appears to be a bug with this- &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;NIM089529: The data access arcpy cursors do not release locks when using with statement&lt;/SPAN&gt;&lt;SPAN&gt;. Otherwise, an easy thing to do to see if it is working is to just watch your workspace in Windows Explorer and see if you see either a shared or exclusive lock file is being applied. They should be pretty easy to spot and will show up as a data type of LOCK.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 15:22:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38639#M3028</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-12T15:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38640#M3029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The second statement should release the locks automatically, but there appears to be a bug with this- &lt;SPAN style="font-style:italic;"&gt;NIM089529: The data access arcpy cursors do not release locks when using with statement&lt;/SPAN&gt;. Otherwise, an easy thing to do to see if it is working is to just watch your workspace in Windows Explorer and see if you see either a shared or exclusive lock file is being applied. They should be pretty easy to spot and will show up as a data type of LOCK.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh yeah look at that. Never noticed that issue before. Deleting the cursor object gets rid of it though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: I can't seem to be able to find the NIM entry on the support page though. Is it new?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 15:32:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38640#M3029</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-03-12T15:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38641#M3030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah, I just entered it last week, so it usually takes a few days.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 15:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38641#M3030</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-12T15:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38642#M3031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;"Otherwise, an easy thing to do to see if it is working is to just watch your workspace in Windows Explorer and see if you see either a shared or exclusive lock file is being applied. They should be pretty easy to spot and will show up as a data type of LOCK."&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would this method of spotting lock files only apply to shapefile, personal and file geodatabases?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would you need to worry about locks from arcpy.da if you are working with an SDE geodatabase that is built to accomodate multiple users?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 15:44:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38642#M3031</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-03-12T15:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38643#M3032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks mzcoyle and ldanzinger!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the tip about using Windows Explorer to monitor locks.&amp;nbsp; It helped me confirm that my first line of code releases the lock, and that using the "with" statement does not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a little note about using Windows Explorer to monitor locks:&amp;nbsp; Since I'm using arcpy.mapping (layer and map document classes as well as cursors) it's difficult to use Windows Explorer to tell when .sr.locks are added/removed.&amp;nbsp; However, even though the lock files don't appear to update in Windows Explorer as additional locks are added/removed, I could isolate/confirm an arcpy object with a lock by deleting all other arcpy objects that &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;could&lt;/SPAN&gt;&lt;SPAN&gt; have locks, and watch the .lock files disappear as I then deleted the arcpy object of interest.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either of you know who might have answers to my other question?&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/79642-Setting-workspace-to-SDE-feature-dataset"&gt;http://forums.arcgis.com/threads/79642-Setting-workspace-to-SDE-feature-dataset&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 16:58:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38643#M3032</guid>
      <dc:creator>KerryAlley</dc:creator>
      <dc:date>2013-03-12T16:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38644#M3033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This may be one way, just came up with it and it is pretty untested, though gives more or less right results for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;lock_list = [item.split('.')[0] for item in os.listdir(your_gdb) if item.endswith('.lock') and not item.startswith('_gdb')]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 17:06:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38644#M3033</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-03-12T17:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38645#M3034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;STRONG style="color: &amp;quot;#FF0000&amp;quot;;"&gt;"Otherwise, an easy thing to do to see if it is working is to just watch your workspace in Windows Explorer and see if you see either a shared or exclusive lock file is being applied. They should be pretty easy to spot and will show up as a data type of LOCK."&lt;/STRONG&gt; &lt;BR /&gt; &lt;BR /&gt;Would this method of spotting lock files only apply to shapefile, personal and file geodatabases?&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Would you need to worry about locks from arcpy.da if you are working with an SDE geodatabase that is built to accomodate multiple users?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It will work well for shapefile and file gdb. Personal geodatabases are a bit different, as locks occur at the geodatabase level. However, you can see the locks on the entire mdb. I only tested the "with" bug on a file gdb, but I imagine the input data type shouldn't make a difference. I would say regardless of what database you are going through and regardless of what technology you are using to do a cursor (i.e. whether through arcpy or not), you should always remove the locks to take them out of memory.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 23:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38645#M3034</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-12T23:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38646#M3035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Edit: I can't seem to be able to find the NIM entry on the support page though. Is it new? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a place to track updates on bugs if we know the number?&amp;nbsp;&amp;nbsp; I'm very interested to see what's going to happen with NIM089529&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apologies if this is stupid questions.&amp;nbsp; I did try googling it for a while, but no luck yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 14:42:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38646#M3035</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2013-04-03T14:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38647#M3036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a place to track updates on bugs if we know the number?&amp;nbsp;&amp;nbsp; I'm very interested to see what's going to happen with NIM089529&lt;BR /&gt;&lt;BR /&gt;Apologies if this is stupid questions.&amp;nbsp; I did try googling it for a while, but no luck yet.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can search for bugs that have been published here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://support.esri.com/en/"&gt;http://support.esri.com/en/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This one still isn't showing up though. I assume Esri has internal bug tracking that they don't publish immediately, or ever, as I have seen numerous NIM references from Esri support that don't ever show up there under the referenced number.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 15:29:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38647#M3036</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-04-03T15:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Clarifying when cursor locks are released</title>
      <link>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38648#M3037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thanks, Mark.&amp;nbsp; I'm feeling a bit concerned about it not showing up.&amp;nbsp; Could this mean that it's not going to be considered as a bug?&amp;nbsp; I've had several interactions with some Esri folks about this and they pointed out that if you run a script from the command line (or double click it to run in directly with python.exe), this bug doesn't occur.&amp;nbsp;&amp;nbsp; Or if you run it in Pyscripter this bug doesn't occur. So one suggested solution was to switch IDE's --sort of implying that this wasn't really a bug.&amp;nbsp; They pointed out several special cases where all the locks ARE deleted.&amp;nbsp;&amp;nbsp;&amp;nbsp; They said they'd change the documentation to match the current behavior--but they never agreed that the behavior needed to change.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This bug even occurs within the ArcGIS Python window, for heavens sake.&amp;nbsp; So...I'm hoping it will get attention very soon.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 17:37:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clarifying-when-cursor-locks-are-released/m-p/38648#M3037</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2013-04-03T17:37:00Z</dc:date>
    </item>
  </channel>
</rss>

