rossko57
(Rossko57)
August 3, 2018, 11:44pm
4
Okay, so you are saying the rule does not get triggered at civilDusk START event? (so the timer never gets created of course)
But sometimes, the rule can run some time much later than expected. On those occasions, do you see the logInfo for rule trigger e.g. hours after civilDusk event in the logs? Followed by timer action the expected 20 minutes later?
I’m thinking along these lines
Here is what might be happening.
The Rules engine has a small number of execution threads. I think the number is 6 but the exact number doesn’t matter. Just know that it is less than 10.
This means you can have no more than 6 instances of Rules executing at the same time.
When you have Thread::sleeps and/or executeCommandLines that run scripts that take more than a few dozen milliseconds to complete you are tying up one of those execution threads until the Rule returns.
When you run out of …
and
EDIT: While the general advice in this article still applies (i.e. it’s always worth while to make short running rules), the problem described in this article only applies to OH 1.x and Rules DSL in OH 2.x. In OH 3 and beyond, this is no longer a problem so if your rules stop running in any version of OH released in the last two years (as of this edit in 1/2023) this is not your problem.
By way of explanation, in OH 3 each rule gets it’s own thread. It is no longer possible for a rule to starve…