<?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 Cannot delete temp gdb on subsequent iterations because of lock in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016890#M59514</link>
    <description>&lt;P&gt;I am having a major problem preventing me from running a python 3x script. I am iterating over dozens of folders and creating lots of temporary data on each iteration. I am creating a temp gdb to store the temp data, then deleting and creating a new one on each pass. I have done this before with no issue, but now, after the first iteration I am getting a lock error&amp;nbsp;Cannot delete C:/WebDev/Projects/...\temp.gdb. May be locked by another application. I want to emphasize that nothing is open, all programs including ArcPro have been closed before running the script and the error persists. I know this is a common issue and am hoping that someone can please give me a work-around. I have also tried just overwriting the gdb, but cannot do that either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found this statement in the esri documentation regarding schema locks:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Scripts may always update the schema of data created by tools within the same script, even if the current workspace is being used by another application."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If I understand this correctly, as long as the data being created from within the script (including the temp gdb) I should not be getting a lock error when attempting the delete it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please shed some light on this?&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jan 2021 15:50:30 GMT</pubDate>
    <dc:creator>FranklinAlexander</dc:creator>
    <dc:date>2021-01-14T15:50:30Z</dc:date>
    <item>
      <title>Cannot delete temp gdb on subsequent iterations because of lock</title>
      <link>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016890#M59514</link>
      <description>&lt;P&gt;I am having a major problem preventing me from running a python 3x script. I am iterating over dozens of folders and creating lots of temporary data on each iteration. I am creating a temp gdb to store the temp data, then deleting and creating a new one on each pass. I have done this before with no issue, but now, after the first iteration I am getting a lock error&amp;nbsp;Cannot delete C:/WebDev/Projects/...\temp.gdb. May be locked by another application. I want to emphasize that nothing is open, all programs including ArcPro have been closed before running the script and the error persists. I know this is a common issue and am hoping that someone can please give me a work-around. I have also tried just overwriting the gdb, but cannot do that either.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found this statement in the esri documentation regarding schema locks:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Scripts may always update the schema of data created by tools within the same script, even if the current workspace is being used by another application."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If I understand this correctly, as long as the data being created from within the script (including the temp gdb) I should not be getting a lock error when attempting the delete it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please shed some light on this?&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 15:50:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016890#M59514</guid>
      <dc:creator>FranklinAlexander</dc:creator>
      <dc:date>2021-01-14T15:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete temp gdb on subsequent iterations because of lock</title>
      <link>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016920#M59515</link>
      <description>&lt;P&gt;is in_memory not an option?&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/modelbuilder/the-in-memory-workspace.htm" target="_blank"&gt;Write geoprocessing output to memory—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 16:29:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016920#M59515</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-14T16:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete temp gdb on subsequent iterations because of lock</title>
      <link>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016929#M59516</link>
      <description>&lt;P&gt;Yes, I did try that and it works great once I have finished developing and testing the script:&lt;/P&gt;&lt;P&gt;tempDB = arcpy.env.scratchGDB&lt;/P&gt;&lt;P&gt;While testing, however, I need to be able to see the temp data so I can troubleshoot my errors and I cannot do that if the temp data is in memory. I did find a solution that seems to be working so far. I just create a fresh temp gdb first (not inside the for loop) and set arcpy.env.overwriteOutput = true. I don't have any lock errors deleting the temp gdb when on the 1st iteration, so that works fine. Just a little frustrating that I have been testing this script for weeks without any issue (even with ArcPro open!) and the last few days I started getting the lock error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the suggestion and it's nice to have that option when setting the script to run on a schedule from the enterprise server. Less that can break!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 16:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016929#M59516</guid>
      <dc:creator>FranklinAlexander</dc:creator>
      <dc:date>2021-01-14T16:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete temp gdb on subsequent iterations because of lock</title>
      <link>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016956#M59520</link>
      <description>&lt;P&gt;With nothing open that access that FGDB, make sure there are no orphaned lock files.&amp;nbsp; If a previous run terminated prematurely or incorrectly, it might be an orphan lock that the script is seeing and not allowing the FGDB to be cleaned up.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 17:13:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1016956#M59520</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-01-14T17:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot delete temp gdb on subsequent iterations because of lock</title>
      <link>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1017034#M59529</link>
      <description>&lt;P&gt;Thanks for the suggestion. I am not sure I am able to check on that since I don't have admin privileges. However, I don't think that is the issue since the script doesn't throw an error on the first iteration. If there is an orphan lock, then I think it is being caused by some process in the script and not by ArcPro or some other program not releasing it. At this point, I have found a workaround, so it's not an issue any more.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 20:01:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-delete-temp-gdb-on-subsequent-iterations/m-p/1017034#M59529</guid>
      <dc:creator>FranklinAlexander</dc:creator>
      <dc:date>2021-01-14T20:01:13Z</dc:date>
    </item>
  </channel>
</rss>

