Sounds like you have a rogue kernel extension running, probably installed by a third-party app. They can be difficult to track down, and will probably require a wipe and reinstall/migration from backup. Even with that, the errant program/kext might get restored in the migration.
In the meantime, while you ponder your strategy, you could use a temporary solution, if only to get your pressing tasks done. You wrote “other than perhaps to never allow the display to close.” Does that mean your task will keep running as long as the display is active? If so, here’s your quick fix:
Go to System Preferences -> Desktop & Screen Saver, click on the Screen Saver tab, click on Hot Corners…
This will let you to temporarily disable the screen saver from turning on. You can select any of the four corners of the screen to place your cursor and perform the command, shown by the choices available, and can be triggered either by placing the cursor in a corner, by itself, or with a key combination. You will want to choose “Disable Screen Saver.” As long as the cursor is there, the screen saver will not kick in. Remember, this is a temporary relief. You still need to trace the root of the problem.
I read about a script that this person uses to keep the cursor “jiggling” in order to fool the computer to sense that the mouse is constantly in motion. I will try to find that article. At the very least, it can be interesting.