Purpose

The example will showcase how to use different Python interpreter sessions in a single execution.

Example File Location

<TestStand Public>Examples\Fundamentals\Python\Interpreter Session Management\Interpreter Session Management Sequence.seq

Highlighted Features

  • Python Interpreter Session Management

Major API

None

Prerequisites

You must have required version of CPython interpreter installed and added to your PATH variable. You must update the Python version to use in the Python adapter configuration dialog before using the example.

How to Use This Example

Complete the following steps to use this example.

  1. On the Steps pane of the MainSequence sequence, review the steps in the Setup step group.
    • The first step, Update Python version to use in all steps, updates the Python version in each step to use the version specified in Python adapter settings. You typically will not do this for an actual test and should instead directly specify the Python version to use in the steps that use the Python adapter. This example can't determine the Python version installed in the computer and therefore modifies the Python version of each step programmatically to match what is specified in the Python adapter settings.
  2. On the Steps pane, review the steps in the Main step group.
    • The Global interpreter session step, which is a Sequence Call step, call the Global subsequence two times to demonstrate Python global interpreter session.
    • The Per Thread interpreter session, which is a Sequence Call step, call the Per Thread subsequence three times on a separate thread to demonstrate Python per thread interpreter session.
    • The Wait for Thread Return step, which is a Wait step, waits for execution completion of the Per Thread subsequence on a separate thread.
    • The Per Execution interpreter session, which is a Sequence Call step, call the Per Execution subsequence on a new execution instance to demonstrate Python per execution interpreter session.
    • The Wait for Executions to Return step, which is a Wait step, waits for execution completion of the Per Execution subsequence on a separate execution instance.
    • The Object Reference interpreter session step, which is a Sequence Call step, call the Object Reference subsequence to demonstrate Python object reference interpreter session.
  3. The Global, Per Thread, Per Execution, and Object Reference subsequence gets and sets Python attribute in the code module.
  4. The Result step in Global, Per Thread, Per Execution, and Object Reference subsequence, which is an Additional Results step, summarizes the results in the report.
  5. Select Execute»Single Pass to run the sequence.
  6. When execution completes, review the report to see the how different interpreter sessions maintain independence from each other.