This is a question for SmartThings software developers.
During smart app development I’ve run into a problem when one of my functions occasionally triggered java.util.concurrent.TimeoutException
which means that it’s exceeded 20 sec execution limit.
With some debugging I was able to narrow it down to calling the unschedule()
API. A simple test revealed that executing unschedule()
API can take anywhere from 90 milliseconds to 3.7 seconds (!). And that’s on a good day. Occasionally, unschedule()
gets stuck for longer than 20 seconds, resulting in java.util.concurrent.TimeoutException
.
Here’s a simple test that I ran:
private def myUnschedule() {
def t0 = now()
unschedule()
def t = now() - t0
log.trace "unschedule() is executed in ${t} ms"
}
And here’s what it prints:
XXXX 10:50:46 AM PST: trace unschedule() is executed in 1420 ms
XXXX 10:50:45 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 10:50:42 AM PST: trace unschedule() is executed in 3652 ms
XXXX 10:50:38 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 10:50:35 AM PST: trace unschedule() is executed in 3744 ms
XXXX 10:50:31 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 10:50:28 AM PST: trace unschedule() is executed in 2383 ms
XXXX 10:50:25 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
A related question is what happens to the smart app once it hits TimeoutException
? I have a suspicion that it’s left in a “zombie” state where it does not properly responds to events and can no longer update its state
.
Any help resolving this issue would be greatly appreciated.
P.S.
Here’s another test tun: unschedule() exceeds 10 seconds (!)
XXXX 11:26:17 AM PST: trace unschedule() is executed in 5045 ms
XXXX 11:26:12 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 11:26:09 AM PST: trace unschedule() is executed in 10467 ms
XXXX 11:25:58 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 11:25:53 AM PST: trace unschedule() is executed in 5153 ms
XXXX 11:25:48 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 11:25:16 AM PST: trace unschedule() is executed in 8093 ms
XXXX 11:25:08 AM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
… and another one: unschedule() exceeding 15 seconds!
XXXX 12:15:08 PM PST: trace unschedule() is executed in 12704 ms
XXXX 12:14:56 PM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 12:15:08 PM PST: trace unschedule() is executed in 14354 ms
XXXX 12:14:54 PM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 12:15:08 PM PST: trace unschedule() is executed in 15502 ms
XXXX 12:14:53 PM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX
XXXX 12:14:51 PM PST: trace unschedule() is executed in 887 ms
XXXX 12:14:51 PM PST: trace Deleting all scheduled jobs for InstalledSmartApp: XXXX