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

**URL:** <https://forum.inductiveautomation.com/t/ign-4437-ignition-occasionally-forgets-how-python-works/69635>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 9, 2023, 4:35pm UTC](https://forum.inductiveautomation.com/t/ign-4437-ignition-occasionally-forgets-how-python-works/69635 "2023-02-09T16:35:02Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 11, 2024, 3:00pm UTC](https://forum.inductiveautomation.com/t/ign-4437-ignition-occasionally-forgets-how-python-works/69635/21 "2024-04-11T15:00:12Z")

</div>

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

```python
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:

> [@Project Library Script Initialization Races](https://forum.inductiveautomation.com/t/project-library-script-initialization-races/98636):
>
> Are you annoyed by pseudo-random breakage in Ignition project library scripting? Odd top-level constants being garbled, or operations in the top level that have side effects running twice? Or more? Not happening much, but always around project edits, and sometimes even on gateway restart? Yeah, me too. frowning_face Poking around under the hood back in the spring, for a module development task, I ran across some problematic IA bytecode and pinged some people. But it went nowhere, as I co…

---

_[View the full topic](https://forum.inductiveautomation.com/t/ign-4437-ignition-occasionally-forgets-how-python-works/69635)._
