<?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 Locked File issue in arcpy loop in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119106#M63024</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I am using the multiprocessing to generate multiple watershed. Each processor uses certain sets of watershed outlet points and the "for loop" to: (1) first generate the snap pour point using-- arcpy.sa.SnapPourPoint() , (2) save the resulted raster, (3) generate and save the watershed which uses the snap pour raster as input , 4) delete the snap pour raster and the watershed raster using&amp;nbsp;arcpy.Delete_management (). The watershed deleted without a problem but the snap pour rasters are locked and can not be deleted. How can i release the lock and delete the file during each run of the loop without closing the program? I am using python 2.7. Many thanks,&lt;/P&gt;&lt;P&gt;Jonas&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Nov 2021 08:00:18 GMT</pubDate>
    <dc:creator>YonasKassa</dc:creator>
    <dc:date>2021-11-22T08:00:18Z</dc:date>
    <item>
      <title>Locked File issue in arcpy loop</title>
      <link>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119106#M63024</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I am using the multiprocessing to generate multiple watershed. Each processor uses certain sets of watershed outlet points and the "for loop" to: (1) first generate the snap pour point using-- arcpy.sa.SnapPourPoint() , (2) save the resulted raster, (3) generate and save the watershed which uses the snap pour raster as input , 4) delete the snap pour raster and the watershed raster using&amp;nbsp;arcpy.Delete_management (). The watershed deleted without a problem but the snap pour rasters are locked and can not be deleted. How can i release the lock and delete the file during each run of the loop without closing the program? I am using python 2.7. Many thanks,&lt;/P&gt;&lt;P&gt;Jonas&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 08:00:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119106#M63024</guid>
      <dc:creator>YonasKassa</dc:creator>
      <dc:date>2021-11-22T08:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Locked File issue in arcpy loop</title>
      <link>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119136#M63025</link>
      <description>&lt;P&gt;Do you have ....&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;set in your script?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 10:52:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119136#M63025</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-22T10:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Locked File issue in arcpy loop</title>
      <link>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119276#M63027</link>
      <description>&lt;P&gt;Hi Dan, Thank you. Yes, i have&amp;nbsp;&lt;SPAN&gt;arcpy.env.overwriteOutput = True declared&amp;nbsp;outside the loop. But still, the Snap pour raster is locked, even if the Watershed raster generated from it is not locked. I tried to generate the Snap pour raster through a function called within the loop. That way, i thought when the function return the raster it would release the lock. Saving the raster alone is not releasing it. The lock on the&amp;nbsp;Snap pour raster is very persistent.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 18:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119276#M63027</guid>
      <dc:creator>YonasKassa</dc:creator>
      <dc:date>2021-11-22T18:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Locked File issue in arcpy loop</title>
      <link>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119302#M63031</link>
      <description>&lt;P&gt;There isn't much that you can do about a python lock, if that is the cause&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 19:35:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119302#M63031</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-22T19:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Locked File issue in arcpy loop</title>
      <link>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119397#M63032</link>
      <description>&lt;P&gt;I believe there is always a way around to address such coding issue. It seems i have solved my problem by working on gdb instead of file directory. My initial code used file directories for the work and scratch space. I have changed that to gdb. The rest of the code is the same, for each loop run it generates Snap pour and watershed rasters save them now in gdb, get the watershed area using curse and then delete the curse (del curse) and the rasters using&amp;nbsp;arcpy.Delete_management, repeat the loop for a different snap point.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 22:50:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/locked-file-issue-in-arcpy-loop/m-p/1119397#M63032</guid>
      <dc:creator>YonasKassa</dc:creator>
      <dc:date>2021-11-22T22:50:23Z</dc:date>
    </item>
  </channel>
</rss>

