I have an application that uses the scratch geodatabase. Upon completion of our work, we delete the scratch geodatabase. The next time our app runs, scratch gets recreated automatically. How do I test for exclusive access to scratch prior to attempting the delete? During some recent debug activities, I had ArcMap open and was consuming some of the feature classes in the gdb. This caused an error when the delete process ran.
If all you need the exclusive access for is to check if it is safe to delete the geodatabase, you could just put the delete command in a try block and ignore any exceptions. Something like
try: arcpy.Delete_management(your gdb here) except: pass
If it is in use it will throw a specific exception (ERROR 000464), detailed here: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000052000000