Hi All
I have noticed an issue with our scripts that have exportToPDF functions (reports and maps). Basically if one of these scripts is run in a task, subsequent scripts do not execute, the export to pdf script does execute and then 'hangs' the task as 'Running'. I have tried putting quit() at the end, but it did not resolve the issue. Any other tips to force close a script after it has run, or clear memory...? Has anyone else experienced such behavior?
In the past, we have had these scripts run perfectly in task scheduler, weird that is has just happened now.
Solved! Go to Solution.
Just wanted to add my solution in case it may help someone, although I can't confirm this is the same problem Peter had.
This behavior was only occurring when Windows Task Scheduler was configured to "Run whether user is logged on or not". Changing this setting to "Run only when user is logged on" allowed the scripts to execute to completion. The service account executing the scripts/tasks should then never be logged off. The service account should also be configured to log in automatically in the case of a server reboot.
Less than ideal, but it has been working in our environment.
I haven't tested in task scheduler, but in a recent script where I was using the PDFDocumentCreate class, ensuring that I delete the objects at the end was in their code samples. This is also required for working with data in GDAL python, not sure if it's a similar reason (C++ bindings or something like that).
# ArcGIS project, maps and pdf document objects
del aprx, maps, pdf
thanks for the advice, have tried it, not successfully unfortunately.
There are a couple of "Related" threads to the right of your post, for example...
Solved: Re: Script using Python API and Windows task sched... - Esri Community
none of those apply?
Are you opening files and the like or using processes that can be controlled by python's context manager?
contextlib — Utilities for with-statement contexts — Python 3.9.6 documentation
Any chance you found a solution to this?
Just wanted to add my solution in case it may help someone, although I can't confirm this is the same problem Peter had.
This behavior was only occurring when Windows Task Scheduler was configured to "Run whether user is logged on or not". Changing this setting to "Run only when user is logged on" allowed the scripts to execute to completion. The service account executing the scripts/tasks should then never be logged off. The service account should also be configured to log in automatically in the case of a server reboot.
Less than ideal, but it has been working in our environment.
Hi Marshal,
Thanks for you tips, i have tested this and it works! I had be juggling the scrip order and running them in multiple tasks. Hopefully we can get notebook server running on our enterprise soon so we can ditch task scheduler.