Hi all, bumping this topic as I’ve been seeing some strange behavior in this regard recently:
TLDR; wondering if there’s a race condition at play when assigning $args.something to a local variable?
I’m building an expandable irrigation system for 4 circuits so far. In short; I decided on a parent-child model, where the parent/master piston executes 4 child pistons, passing a set of arguments/parameters over to them. The 4 child pistons are exactly identical except for which device (solenoid valve) they are controlling and a friendlyname. Everything else like duration is passed down as arguments from the parent.
The funky thing I experienced is that although functionally identical in code to it’s duplicated siblings, one of the child pistons would NOT receive it’s arguments, i.e. they were all null. I found this thread, however although related by title, it was about calling pistons with parameters via URL. The difference that here it’s just one piston calling another.
I debugged the heck out of it and it appeared that SOMETIMES the child piston would gets it arguments, yet most times not, which led me to contemplate if this argument transference business perhaps is subject to a race condition of sorts. I’d really like to ask you guys for feedback if you have any experience to corroborate this theory?
I should add what really freaked me out is that while this problem appeared between the master/parent piston, who’s job it is to schedule irrigation events, the problem did NOT manifest itself when I called the offending child piston from a second egg-timer/manual parent piston.
I can’t say for sure that I solved or nailed it it, as it’s a bit of a belt-and-suspenders hack I’ve implemented to see if it would make a difference. Yet what I frankensteined seems to have held up so far:
- I moved the definition of the local piston variables being assigned to $args.whatever up to the beginning of the definition block and ordered them in the same order as the arguments are applied (alphabetically it would appear)
- I put a Do-With-Location block in, which sets the variables manually right at the top of the piston. This may be unnecessary as I understand variables can be initialized with default values at runtime by setting that up in the definitions workshop. However based on what I’ve seen, it would appear this isn’t always the case.
If you would be kind to help me understand what might be going on here besides the usual Ghost in the Samsung, I would very much appreciate it
Thanks,
/Max