How things work - how much code is allowed behind tag event?

My current understanding is that tag events scripting is only meant for small code like copying the value to other tag, capturing timestamp, checking logic or arithmetic operation. My understanding is that tag events errors do not show up so can go unnoticed. So from code reliability point of view:

1 - How can i know that i didn't put too much code behind tag event? Is there a way to capture an error?
2 -if there is too much code and the next tag cycle update has to happen the unfinished code will be abandoned? Lets assume there was some silly code like database time consuming operation
3 - tag event code which is behind the tag updated every 1s might work but behind tag updated every 100ms might not - is it right?
3 - if there is heavy load with thousands of tags in the tag provider - then tag opc refresh time might be affected and configured tag group update rate might not be met which might impact tag event script?
4 - tag event should be used only when suitable for the purpose (timestamp capture, simple logic, tag write) but not for executing shared project module (gateway tag event is best suited for that)

Please correct me on anything and thanks in advance for any knowledge shared.

First, there are many discussions on this forum about such things. But to summarize:

1a) If the script takes more than single digit milliseconds, it is almost certainly too long.

1b) Yes, get a logger with system.util.getLogger(). Use double except: blocks to catch jython and java errors separately. Use the PythonAsJavaException() wrapper from to let you log jython exceptions as if they were java.

2) Tag events queue if they overrun, per tag, up to five entries. If they overrun that, the missedEvent flag is set. Don't do silly code in tag events. (I would not do database operations.)

3) Yes, all tag events share one thread pool, that has three threads by default. If you have three slow events running at the same time, the whole tag event system is blocked. Don't do that. (You can tweak the thread pool size in ignition.conf, but that isn't really a get-out-of-jail-free card, just an option for really large systems.)

4) Correct. A gateway project-based tag change event can be configured to use a dedicated thread. And those have unlimited queues. So they won't lose an event, and won't block the rest of the system. (Unless there are so many events it can never catch up, in which case the gateway will run out of memory and crash.)


thanks a lot for sharing this