Scripts with .exportToPDF() lock up Windows Task Scheduler

813
6
Jump to solution
08-30-2021 04:13 PM
PeterMilenkovic
Occasional Contributor

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.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Marshal
New Contributor III

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.

View solution in original post

0 Kudos
6 Replies
nzjs
by
New Contributor III

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

 

 

0 Kudos
PeterMilenkovic
Occasional Contributor

thanks for the advice, have tried it, not successfully unfortunately.

0 Kudos
DanPatterson
MVP Esteemed Contributor

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


... sort of retired...
0 Kudos
Marshal
New Contributor III

Any chance you found a solution to this?

0 Kudos
Marshal
New Contributor III

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.

0 Kudos
PeterMilenkovic
Occasional Contributor

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.

0 Kudos