Auto Kill Switch Script RAM and/or Timeout

Hi all,

I’ve been wondering if killing a script/Gateway Scope can be canceled further than manual action hitting on “Cancel”. and do it automatically

I think is simple to implement a self.interrupt with ScriptManager using threadId and setting a timeout with .invokeLater() maybe.

Regarding RAM, should I add a Tag Event Script to Memory Usage tag when values get upper something, try to get this threadId and kill it? Because the other day this happened

Can anyone recommend a better solution or another approach for this?
Any Pseudo - Code advice?

Such efforts just add more workload to the gateway, IMNSHO. Perhaps you are familiar with the aphorism “physician, heal thyself!”

Add logging to you scripts to time them and highlight trouble spots. Then crush the bugs and/or inefficient algorithms.

Or, sometimes, you prove you just need more/better hardware.

1 Like

Nice aphorism.

Indeed script does good. All inefficient algorithms were improved. It does it in few millis around 50ms.
The “slow” part if when using system.tag.queryTagHistory() for 6 months data in 1 hour interval. This functions has no timeout parameter so I want to kill the thread if querying data takes too long.
Limiting the start and end date if not an option for customer.

The hardware there is just a local testing machine haha :grinning_face_with_smiling_eyes:

It was possible, unexpectedly not hard.