When I use Task Scheduler to run a Python script that references an APRX containing our Tracks layer from Location Sharing (Enterprise), and I am NOT logged in, a persistent COM Surrogate is created. I have a script I want to run every 5 minutes but cannot because these COM Surrogates build up and create problems.
I am looking for suggestions to avoid this issue!
Here are our specs:
The script in question creates polylines from Tracks collected that day and appends them to a referenced feature service. These allow users to see each other's tracks in the field, updated every 5 minutes, which is useful for ensuring complete coverage for our monitoring work. (Tracklines are automatically created from Tracks in AGOL, but sadly this functionality does not exist for Enterprise.) I can just stay logged into the AVD machine at all times to prevent COM Surrogate issues, but I have been told this is not a sustainable solution.
Have you tried using ArcGis Pro's built in scheduler? do you have to reference the aprx?
I think ArcGIS Pyton API can query & append without touching an APRX.
Is this happening with a Python script? If so have you looked into killing the interpreter after it runs? Could be that you haven't properly cleaned up the environment and since there isn't a user process to kill those locks.