Prevent Action Groups from executing

Posted on
Tue Jan 11, 2022 10:37 am
Turribeach offline
Posts: 406
Joined: Feb 06, 2015
Location: London, UK

Prevent Action Groups from executing

I got a Schedule which has 3 Actions. Each Action executes an Action Group which is in effect a shell script. I run this schedule every 2 seconds. The scripts helps me getting the state of certain things like my Mac monitors, my Zoom connection and my computer's bluetooth. The scripts work fine 99% of the time but for some weird reason when Parallels does some heavy duty disk work (like Windows 10 updates or disk reclaim) sometimes this will cause some of these scripts to get locked. This wouldn't be a big issue if it wasn't by the fact that I run them every 2 secs. This means that very quickly a lot of processes start to accumulate in the background and eventually the Mac becomes unresponsive. So how can I prevent this situation? Obviously I could try to change these scripts into actual programs which hook into MacOS APIs so that I can run them as a deamon and rather than polling every 2 seconds I can develop something that updates Indigo variables when needed. But I think it will be an overkill and not worth the trouble. The scripts as they are work fine, if I can add some logic to prevent them from executing again if the previous execution is not finished that will do the trick I think. I thought of creating some semaphore files so I can create a file when the script starts and delete it after it's done but I will be writting to the disk all the time so not the best idea when using SSDs. What about using Indigo variables? Are these stored in memory only? Otherwise how can I control that my Action Group scripts don't run again if they are stuck in the previous execution without writing to disk?

Thanks!

Posted on
Tue Jan 11, 2022 1:30 pm
jay (support) offline
Site Admin
User avatar
Posts: 17595
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Prevent Action Groups from executing

Indigo variable changes are not immediately flushed to disk - the db is in-memory until it flushes periodically (or on quit).

I personally would just rewrite the script(s) in Python, then start them as external scripts on server start. That way, if they periodically take longer to run a cycle, then no big deal. I suppose you could run the scripts from a Python script, which would do the same (though with multiple levels of script).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jan 12, 2022 5:38 am
Turribeach offline
Posts: 406
Joined: Feb 06, 2015
Location: London, UK

Re: Prevent Action Groups from executing

Hi Jay, you are right, I don't need to go full blown rewrite to create a proper daemon, I can just do it in a single script looping for ever outside Indigo. That way I will avoid to have to keep a state somewhere else and also I can update the Indigo variables I need only when they change.

Thanks!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest