User interaction disallowed -- Dialog toolkit giving up

I have an app that uses dialog tool kit in a repeat loop. It displays the dialog tool kit window, and if the user does not interact it gives up after a set number of seconds, then repeats (each time with updated info).

It works perfectly, until some time after the mac goes to sleep (but not immediately) the script throws an errorL

'AppleScript Execution Error
User interaction disallowed’

So it seems like either the giving up, or displaying the window, is seen by the mac as user interaction when the mac is in sleep mode.

Any suggestions on how to avoid this? I simply trap for the error, if it’s unavoidable.