POST
|
One possible solution is to use the scratch workspace instead of creating your own temp workspace. The lock will still be created in the scratch workspace (it only exists while the python process is running, just like before), but the scratch workspace isn't intended to be deleted, so you won't need to do any cleanup afterwards. Arcpy will always have access to create the same scratch workspace for each process that is created. In my case the scratch workspace is created in C:\Users\{user}\AppData\Local\Temp\scratch.gdb. Here is the sample script from above, modified to use the scratch workspace instead: import arcpy
arcpy.env.workspace = arcpy.env.scratchGDB
arcpy.management.CreateFeatureclass(arcpy.env.workspace, "Test", "POLYGON", None, None, "ENABLED", "PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]];-20037700 -30241100 10000;#;#;0.001;#;#;IsHighPrecision", None, 0, 0, 0)
layer = arcpy.MakeFeatureLayer_management('Test', 'NewTest')
# No cleanup required here.
# The scratch workspace is recreated every time it is used.
# Pretend it never existed!
... View more
05-07-2018
12:15 PM
|
1
|
0
|
4659
|
POST
|
This is logged as BUG-000086232 here: https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDA4NjIzMg==, but there is currently no plan to resolve it.
... View more
05-07-2018
10:39 AM
|
0
|
0
|
4659
|
POST
|
Scott Davis - I am experiencing the exact issue you describe, but I am using ArcMap Desktop 10.5.1 using Python 2.7. Here's my workflow in a single script: 1. Create temporary gdb and feature class (on C:\temp for speed) 2. Create feature layer from feature class (in-memory) to perform some analysis 3. Output results to desired destination 4. Delete temporary gdb (fail) Robert LeClair - The lock will remain for asynchronous processes until the python process has ended (and raised an error in this case), so adding time.sleep() during the process has no impact. I can delete the gdb in a separate process once the first process has ended. Shaun Walbridge - 1. The lock gets added to the source data and has no impact on the feature layer, so using in-memory for the feature layer does not help. 2. Not sure how you can make a feature layer from a feature class that has been deleted. 3. This appears to be the only solution for now.
... View more
05-04-2018
04:23 PM
|
1
|
0
|
4659
|
Title | Kudos | Posted |
---|---|---|
1 | 05-04-2018 04:23 PM | |
1 | 05-07-2018 12:15 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|