At concept/rules: state that a rule cannot be executed in parallel by dilyanpalauzov · Pull Request #2573 · openhab/openhab-docs · GitHub I proposed spelling out that the execution of one rule cannot be started, as long as the same rule is currently running.
But if you cancel a timer while its executing I would expect an InterrputedException
If Thread.sleep() is in a rule file, the file is changed, while sleep is working, then there is an exception. E.g. DSL logs “Script execution of rule with UID ‘a-1’ failed: sleep interrupted in …” and from JS it is
Failed to execute rule ABC-4110964a-e42b-4f68-afa7-ddd4ab70af93: java.lang.InterruptedException: sleep interrupted: sleep interrupted
at java.lang.Thread.sleep0
at java.lang.Thread.sleep (Thread.java:509:0)
at execute (a.js:9:247-287)
at doExecute (openhab.js:2:58571-58601)
as demonstrated at rules_overview.md: elaborate about concurrency support in rule engines by dilyanpalauzov · Pull Request #2565 · openhab/openhab-docs · GitHub
A script action can return a value, that is then returned from ScriptActionHandler::execute and I think the RuleEngineImpl passes that value to the next module. If the next module is a script action, the value can be simply injected into the context if core wants to do that.
Is that value passed by inputs["result"]
(parameter of SimpleRule.execute(action, inputs)`) to the next action, or by injections of terms of ScriptEngine.put()?
If we want to allow for truly parallel execution of the same transformation, I could imagine switching from the one engine per transformation script mechanism to having a pool of ScriptEngines for each language and executing in ScriptEngines that are currently free. Basically like a thread pool.
I think it is sufficiant to state, that no global variables should be used. In case of JS this probably means wrapping everything in { ... }
or in IIFE function( ) { }()
. Writing transformations means that, unless absolutely necessary, no variables should be used, which outlive the current script execution.
I think the only „up-to-date“ language that‘s well maintained and is not Graal is Ruby
What are the problems with Groovy, except [Groovy] TriggerBuilder not in RuleSupport preset since OH 4.3 · Issue #18396 · openhab/openhab-addons · GitHub (importPreset
not importing types)?