david12385

Upgraded to ArcGIS Pro 2.6: arcpy.CreateFileGDB_management() now leaving an sr.lock

Discussion created by david12385 on Aug 6, 2020
Latest reply on Sep 18, 2020 by clogan-esristaff

Hello,

 

To summarize my current workflow, I use tkinter in Python 3.x (Esri's release that accompanies each Pro update) to execute some Esri geoprocessing functions for exporting SDE data (Create local File GDB, export feature classes from the SDE into the File GDB, run some field calculations, zip up the File GDB, etc.).

 

This workflow has been working just fine for me these past few minor releases of Pro. However, with the recent upgrade to Pro 2.6, I'm running into errors related to arcpy's CreateFileGDB_management().

 

When I create a file geodatabase through arcpy, it's leaving a "_gdb" sr.lock in place even after the file geodatabase has been created.  All other functions that occur after this step (export feature classes, field calculations, etc.) properly release their locks upon completion. However, this one lock gets stuck for some reason during the File GDB creation step.

 

 

 

This has caused some of my applications to have problems with regard to zipping and migrating data due to the lock persisting.

 

After some experimentation, I can get the sr.lock to release by executing the arcpy.ClearWorkspaceCache_management() option. However, I've never needed to use this previously when creating local File GDBs.

 

Is this sr.lock working as intended, or could there have been a bug introduced in Pro 2.6? Again, this has not been an issue for my tools in Pro 2.x prior to 2.6, so I'm curious if anyone is encountering this issue now as well. Thanks for your assistance!

 

Here's my code for this particular function, and this is where I've isolated the sr.lock hanging:

 

   

def func_Create_GDB(self):

        # This function creates an empty File GDB that will be used to house the exported Regional SDE feature classes.


        try:

            # This string creates a naming convention for the new QC Prepped GDB.
            self.gdb_name_prepped = stat_val.gdb_name_prepped + "_" + self.input_zip_file_name_date_only

            # Display message within scrolled text box.
            self.func_Scroll_SetOutputText("Creating File GDB:\n" +
                                           self.gdb_name_prepped + stat_val.string_gdb + "\n" +
                                           "Saving to:\n" +
                                           self.output_folder + self.input_zip_file_name_date_only, None)

            # Creates the File GDB with the new GDB naming convention.
            arcpy.CreateFileGDB_management(self.output_folder + self.input_zip_file_name_date_only,
                                           self.gdb_name_prepped)

            # Display all geoprocessing messages within scrolled text box with blue text.
            self.func_Scroll_SetOutputText(arcpy.GetMessages(), stat_val.color_Blue)

            # Increment progress bar by 2 percent.
            self.percent_value = self.percent_value + 2
            self.func_ProgressBar_SetProgress(self.percent_value)

            # Once task has completed, display message within scrolled text box.
            self.func_Scroll_SetOutputText("Output GDB created!", None)

            # Change function check message from Failure to Success.
            self.check_func_Create_GDB = stat_val.message_Success

        except arcpy.ExecuteError:

            # Display message within scrolled text box.
            self.func_Scroll_SetOutputText(arcpy.GetMessages(2), stat_val.color_Red)

            # Set progress bar to 100 percent.
            self.func_ProgressBar_SetProgress(100)

            # Set completion boolean to False if failure occurs.
            self.check_complete = False

Outcomes