I am running into a bit of a problem with the way that ArcGIS Pro 3.1 locks the APRX files when scripts access them using arcpy modules. The process that was developed in 2.X makes a copy of a blank project (because you can’t create a new project using arcpy) that is pasted into a temporary location. The script then adds in the .pagx files that are used as a map/layout template for the generated maps. In 2.X, after the maps are made using arcpy, the script cleans up those temporary APRX files by using os.remove(). However, in 3.1, the temp APRX file remains locked until you close down the APRX file that you ran the script from, causing the files to build up in the temp location. Some things I have tried so far:
Other details:
1. ArcGIS Pro install is on a Windows 2016 Server
2. The write location of the APRX files is in a location on the server that gets cleaned up after the user signs out of the server. This location did not cause an issue with ArcGIS Pro 2.X
Thank-you in advance for any help or assistance!