<?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: Error handling on locked geodatabases in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708903#M54956</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The file geodatabase exists solely for this purpose and should not have any other locks on it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Jul 2012 11:14:47 GMT</pubDate>
    <dc:creator>MarcCusumano</dc:creator>
    <dc:date>2012-07-18T11:14:47Z</dc:date>
    <item>
      <title>Error handling on locked geodatabases</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708898#M54951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am doing some error handling on a python script that loads features into a file geodatabase from SDE and then restarts an ArcServer instance. I'm stuck at the point where I try to get the process to run through an inability to delete an old file GDB due to a file lock. Here is the code I am trying (snippet from full script):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete Old File Geodatabase &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.rmtree(OldFileGDBPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Deleting Old File Geodatabase..." &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.info("Deleted %s" %(OldFileGDBPath))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Rename New File Geodatabase &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.rename(FileGDBPath, OldFileGDBPath) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Renaming New File Geodatabase..." &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; logging.info("Renamed %s %s" %(FileGDBPath, OldFileGDBPath))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except (IOError, TypeError, NameError) as e: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "I/O error({0}): {1}".format(e.errno, e.strerror) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However this does nothing to prevent the un-handled exception and stops the program from running. Thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 14:18:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708898#M54951</guid>
      <dc:creator>MarcCusumano</dc:creator>
      <dc:date>2012-07-16T14:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling on locked geodatabases</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708899#M54952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are any ArcGIS Server services accessing data within the File Geodatabase you are trying to delete?&amp;nbsp; This will cause a lock and prevent you from deleting the geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Replicas_and_geodatabases/003n000000vp000000/"&gt;replication&lt;/A&gt;&lt;SPAN&gt; replace the copying of feature classes to a new File Geodatabase?&amp;nbsp; You could then perform a synchronization rather than a copy/paste of feature classes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 14:56:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708899#M54952</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-07-16T14:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling on locked geodatabases</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708900#M54953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I suppose that would work but we already have the code set up to do a quick copy of a handful of features to a new file gdb, delete the old, and rename the new. I just need a quick way to handle an exception where the shutil.rmtree command cannot execute due to a file lock.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 15:38:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708900#M54953</guid>
      <dc:creator>MarcCusumano</dc:creator>
      <dc:date>2012-07-16T15:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling on locked geodatabases</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708901#M54954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to pass the error when I used 'arcpy.Delete_management' to delete the File Geodatabase and a lock was present.&amp;nbsp; See if this will work for you.&amp;nbsp; Here is an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import os, logging, arcpy&amp;nbsp; OldFileGDBPath = r"C:\temp\python\Old.gdb" FileGDBPath = r"C:\temp\python\New.gdb"&amp;nbsp; try:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete Old File Geodatabase &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(OldFileGDBPath) &amp;nbsp;&amp;nbsp;&amp;nbsp; print "Deleting Old File Geodatabase..." &amp;nbsp;&amp;nbsp;&amp;nbsp; logging.info("Deleted %s" %(OldFileGDBPath))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Rename New File Geodatabase &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Rename_management(FileGDBPath, OldFileGDBPath) &amp;nbsp;&amp;nbsp;&amp;nbsp; print "Renaming New File Geodatabase..." &amp;nbsp;&amp;nbsp;&amp;nbsp; logging.info("Renamed %s %s" %(FileGDBPath, OldFileGDBPath))&amp;nbsp; except Exception as e: &amp;nbsp;&amp;nbsp;&amp;nbsp; print e &amp;nbsp;&amp;nbsp;&amp;nbsp; print "passing error" &amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jul 2012 16:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708901#M54954</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-07-16T16:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling on locked geodatabases</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708902#M54955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Marc:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are the file geodatabases that you are using dedicated to ArcGIS Server mapservices?&amp;nbsp; If so, you should make sure that there are no locks lingering around after you stop the associated mapservices.&amp;nbsp; Maybe the file geodatabases are also available to other endusers for their data which would place locks on the file geodatabases.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you made sure that all services that are hitting the file geodatabases are stopped when you try to deleted the file geodatabases?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another solution that unfortunately would need more coding would be to truncate and append data from SDE to the file geodatabases.&amp;nbsp; This operation does not crash due to schema locks as the structure of the file geodatabase remains the same.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jul 2012 20:05:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708902#M54955</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-07-17T20:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling on locked geodatabases</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708903#M54956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The file geodatabase exists solely for this purpose and should not have any other locks on it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2012 11:14:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-on-locked-geodatabases/m-p/708903#M54956</guid>
      <dc:creator>MarcCusumano</dc:creator>
      <dc:date>2012-07-18T11:14:47Z</dc:date>
    </item>
  </channel>
</rss>

