I’m playing around with multi-project inheritance trees, for example where two runnable projects inherit from a single “Global” project, to see how project saves impact inherited script libraries, and i’m seeing odd results that I can’t explain.
I set something dumb up just for testing… I know you shouldn’t perform tag reads/writes within the root of a script library. However…
I have this script library defined in my Global project (which is not overridden in either of the two inheriting Main projects):
tagPath = '[default]Testing/Test 2'
oldVal = system.tag.readBlocking(tagPath)[0].value
r = system.tag.writeBlocking(tagPath, oldVal + 1)
system.util.getLogger('BOB').info('{} -> {}'.format(oldVal, r))
Every time the library reloads it should increment the Test 2 tag value by 1.
- If I save the Global project, it increments 1 (I kind of expected it to flakily increment 1 or 2 depending on the speed that each Main project reloads the script library…)
- If I save the “Main” project, it increments 1. Edit: If I set the GSP to the Global project, it doesn’t increment at all.
- If I save the “Main2” project, it doesn’t increment at all.
I’m just looking to understand what’s happening here. I would have expected saving Main2 would also increment the tag value by 1, but it’s not. And why does saving Global not write 1 or sometimes 2?
Projects defined:
Edit:
Note: the Main project is the global scripting project (GSP).
It seems to have to do with the GSP, but I would have expected a change to an inherited script library would reload it in all inherting projects which would then run it and therefore write to the tag in all locations. I added a lock to get rid of the race condition where two threads could read the current tag value at the same time and hence increment by 1 always instead of 2:



