Error When Passing Objects Between Python Interpreters in TestStand

Updated Sep 10, 2019

Reported In

Software

  • TestStand

Issue Details

I get the following error when I run my TestStand sequence.  

Unable to use PyObject created in another python interpreter session. You can use PyObject which is created in same python interpreter session. 
 


 

Why is this happening and what can I do to resolve it? 

Solution

When a Python object is created, it is done so within a given interpreter. The objects created within one interpreter cannot be shared with another interpreter. The interpreter that a given code module is using can be configured using the Adapter Settings or the Advanced Settings of the Python Step.  

The Python Adapter can be configured to use interpreters on a Global, Per Execution, or Per Thread basis. The TestStand Help documentation explains what each of these settings do.  
 

  • Global—All Python modules execute in a single instance of the Python interpreter.  
  • Per Execution—Each execution uses a separate instance of the Python interpreter to execute modules.  
  • Per Thread—Each thread uses a separate instance of the Python interpreter to execute modules.  

An individual Python step can choose to use the Adapter Settings or an Object Reference for its interpreter session, creating one if it does not exist. These settings are accessed through the advanced settings button in the Step Settings. 

Given the possibility of multiple interpreters, it is important to keep track of which objects belong to which interpreter. If an object reference from one interpreter is brought into TestStand, it must be used within that interpreter in subsequent steps.