[IGN-4437] Ignition occasionally forgets how Python works?

If you cannot do my option 4, consider this option 5, superior to option 3:

c = Constants
system.db.runNamedQuery(c.GET_PATH, {c.XYZ_ID_COLUMN_NAME:variable})

The fundamental issue is that Ignition is extremely multi-threaded, including for the jython interpreters. Note the "s" on interpreters. Some multi-threading issues that cannot occur in CPython, due to its single interpreter lifetime, absolutely can occur with jython in Ignition.

A piece of your code that triggers the lookup of Constants could be racing with a project edit that is being applied. So two lookups of Constants, even though back to back in your code, could get old and new versions. One lookup, followed by nested var lookup, ensures that they are from the same code context.

This is the kind of race that can cause your Task versus QCTask type mismatch.

This is one of the reasons that I strongly recommend that ALL event scripts and transforms, everywhere in Ignition, delegate (in a single statement) to a project library script function, passing all relevant event variables as arguments to the function. Only the lookup of the function traverses Ignition's auto-import code.

Edit: This long-standing bug in project library script "auto import" is likely a contributor to the odd behavior here:

3 Likes