Tag event script fails, same code in button works

Sometimes my tag event scripts stop working and will not restart until I restart the gateway. Calling the script from the Script console or from a button on a project window works just fine all the time, even when the tag event scripts stop working. I suspect I am getting some exceptions swallowed up and not handled properly by I can’t find them, even using system.util.getLogger calls in my shared function.

Using gateway 7.9.14

Question:

  1. Do all tag events “value changed” scripts run on the same thread ?
  2. If there is an exception on in the tag event context does it kill all the other tag events ?
  3. How do you catch exceptions that run on the tag event context ?

I wrote a shared (global) routine to copy tag values from one UDT to another UDT where the tag names match.
I am calling this in a “value changed” event on a system expression tag. The system expression tag contains the expression “getSecond(now(1))” so it changes every second.

The “value changed” script is called like this:

shared.OPCUAservices.Steering_OPCUA_service.writeToSubscribers()

That function basically makes two lists of matching tag paths and uses functions to read values from one list of tags and write them to another list of values.

tags = system.tag.readAll(readTagPathList)
.... more code to make a list of tag values
system.tag.writeAll(writeTagPathList,tagValues)

All tag paths complete with the device prefix. For example: “[s1500]_TESTJVSC/_test”