03-27-2023 11:47 AM
Is using python's multithreading module in a TestStand python adapter step supported? This step's code works fine in python but hangs when called from from TestStand.
I've attached a simple example to demonstrate.
TS2022q4, python 3.10
Possible alternatives: use TS to do the threading or use a call executable step.
Solved! Go to Solution.
03-27-2023 01:09 PM
You can use `multiprocessing` module in any function/class called from TestStand's Python adapter. Before creating instance of `Process`, you need to use `multiprocessing.set_executable` by pointing to the python exe you want to use for multiprocess.
Reason: TestStand executes Python modules in an external process which embeds CPython interpreter. By default, `multiprocessing` module uses `sys.executable` which will be the path of current executable (which is the process shipped along with TestStand). TestStand's executable is designed to work only when called from TestStand. If using `multiprocessing` module, you will be calling TestStand's executable from Python which does not work since the parameters are not understood by the exe. Hence, in your code, explicitly mention the Python executable to be used for multiprocessing.
Note: We do have plans to for improving the behavior where multiprocessing works out of the box.
03-27-2023 04:10 PM
Thanks so much for the explanation. Calling out the path of the current python executable works as you described.