I have some questions about “living” copies of global script modules.
My team is working on a Check In / Check Out scanning system that will have multiple Perspective sessions running, and they will all reference the same set of global scripts (inherited) through the same Child Project. There are a few module-level variables that we use, but we have seen a few instances of people using the module-level for initializing common variables between different local functions (i.e. errorMsg = “” is used in def func1(), def func2(), etc…).
As a curiosity, we decided to test these scripts with the python “id()” function to see if there are any possibilities of stepping on each other during simultaneous executions.
Here is what we found based on those tests:
- Tags with Value-Change-Events will ALL share the same copy of a script module. (These immediately launched asynchronous threads, but they all had the same ID-address.)
- Perspective Sessions will ALL share the same copy of a script module, but this is a different copy from what the Tags use.
- Vision Clients ALL share the same copy of a script module, but again, this is different from the other copies above.
- On a previous project, it seemed like Gateway Events (tag change, timer, etc. ) shared script copies SOMETIMES, but not all the time. I am not sure how that could occur.
- We have not yet tested the same script module across different Child Projects.
Am I understanding this correctly?
Is this a common method of execution that may be explained elsewhere for java or python?
Are there any other caveats we should look out for?