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

1545
3
08-06-2020 12:07 PM
DavidLindsey2
New Contributor II

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
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
3 Replies
CooperLogan
Esri Contributor

Hello David Lindsey

This sounds like an issue which has been logged as a defect with Pro 2.6.  

[ BUG-000133976: Unexpected behavior creating file geodatabases at 2.6 ]

Please let me know if you have any questions!

Cooper

0 Kudos
DonMorrison1
Occasional Contributor III

I just upgraded to 2.6 and my applications are broken for the same reason.  I really need a fix or a circumvention immediately - please.

0 Kudos
CooperLogan
Esri Contributor

Hey Don,

Just to follow up on this, which we also discussed in the other thread:

arcpro 2.6 arcpy fgdb lock files not clearing 

Like David Lindsey‌ mentions here, the arcpy.ClearWorkspaceCache_management() tool clears this issue up in many cases.  If that doesn't work, please provide some more info on your exact code or reach out to Esri Tech Support for further troubleshooting!

Thanks!

Cooper

0 Kudos