Unable to use PyObject Error -17311 in TestStand

Updated Dec 19, 2024

Issue Details

In TestStand I am running Python code modules that open references to external code. I'm storing these references in StationGlobals and I get the error below between executions when calling the module from a different location.

Error -17311

Solution

Station Globals are not reset when the execution finishes or when you close out TestStand. Therefore, if a PyObject was created for the first time without resetting the Station Global back to Nothing and clicking on File >> Unload all Modules, the current niPython Host instance would be destroyed. Subsequently, when running the sequence again, a new niPython Host instance is created, which will not accept that previously created PyObject.

 

The solution is to either change those variables to FileGlobals instead of StationGlobals or explicitly set the Object Variables to "Nothing" using a statement step.

 

 

Additional Information

Versions: Python 3.11, TS 2024