Python module not recompiled when imported in another script

I have 2 scripts in the script library [project]. The second script imports the first with the following line.

from project.myFolder.myFirstScript import myClass

A function in the second script is called in the designer. If I make a change to myClass, commit the change, then save the project. The function in the second script still calls the old definition of myClass. It only updates the definition of myClass once I re-open the project.

Is this expected behaviour? I am using Ignition 7.9.2

It’s expected behavior. Script modules are effectively executed just once, the first time they are imported. Editing a script forces a reload (re-run) of that script. Your second script, unedited, runs the first time it is referenced, and it imports from your first script at that time. You need a change to the second script to trigger its reload after changing the first script.


The workaround is to not import the class in the second script, but to always reference it by its fully-qualified name.

1 Like

Thank you Phil. The issue is solved when I reference the class using its fully-qualified name.