Page 1 of 1

osExecute & dzVents.lua running more than 10 secs

Posted: Monday 05 October 2020 11:02
by tezzlicious
I noticed dzVents warning me about dzVents.lua has been running for more than 10 seconds.

I recently migrated some more complex cron tasks to dzVents, because it gives me more flexibility/efficiency to run specific tasks depending on device states.

My questions are:

- Does it do any harm when this happens? Is there a possibility that dzVents waits on these tasks before executing other parts that other scripts may depend on?

- Is there a way to trace back which script causes this warning?

- Is there a way to fire and forget these tasks, so dzVents doesn't squawk? Or is there a way to suppress this error for specific scripts?

Thanks!

Re: osExecute & dzVents.lua running more than 10 secs  [Solved]

Posted: Monday 05 October 2020 11:20
by waaren
tezzlicious wrote: Monday 05 October 2020 11:02 I noticed dzVents warning me about dzVents.lua has been running for more than 10 seconds.
- Does it do any harm when this happens?
Yes. No other eventscript can execute until the long running one finished. The domoticz event system is single threaded so only one dzVents / classic Lua / Blockly script can run simultaneously.
- Is there a way to fire and forget these tasks, so dzVents doesn't squawk? Or is there a way to suppress this error for specific scripts?
Yes.

Linux: Append & to the os.execute .
Windows: Prepend start /B to the os.execute.
This will execute the os command in background returning the control back to dzVents directly after firing the command

examples:

Code: Select all

os.execute("sudo find / -name domoticz.sh > findResult") -- could take some time
os.execute("sudo find / -name domoticz.sh > findResult &") -- Executed in background on linux
os.execute("start /B dir > test ") -- Executed in background on Windows

Re: osExecute & dzVents.lua running more than 10 secs

Posted: Monday 05 October 2020 11:37
by tezzlicious
Is this error given for each script taking longer than 10 secs or does it also apply to a chain of scripts being run on a specific time?

Thanks Waaren.

Re: osExecute & dzVents.lua running more than 10 secs

Posted: Monday 05 October 2020 13:31
by waaren
tezzlicious wrote: Monday 05 October 2020 11:37 Is this error given for each script taking longer than 10 secs or does it also apply to a chain of scripts being run on a specific time?
It applies to the sum of execution times of all scripts executing in one dzVents pass. e.g. All script executing at the same time trigger or all scripts executing on the same devices / scene / httpResponse .. etc.. trigger.
That's why it is important to prevent blocking a scripts continued execution because of waiting for (the completion of) an external command or -event.

Re: osExecute & dzVents.lua running more than 10 secs

Posted: Monday 05 October 2020 15:05
by tezzlicious
waaren wrote: Monday 05 October 2020 13:31
tezzlicious wrote: Monday 05 October 2020 11:37 Is this error given for each script taking longer than 10 secs or does it also apply to a chain of scripts being run on a specific time?
It applies to the sum of execution times of all scripts executing in one dzVents pass. e.g. All script executing at the same time trigger or all scripts executing on the same devices / scene / httpResponse .. etc.. trigger.
That's why it is important to prevent blocking a scripts continued execution because of waiting for (the completion of) an external command or -event.
Ah that explains it. Think I've started exceeding the 10 secs then on *:00 and *:30 marks. More than 250 active dzVents scripts in total running in domoticz. Ranging from simple to complex. I'll start looking into optimizing some things, especially on the timer side.