NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Python Adaptor - TestStand 2019: scripts not running reliably

Hi,

 

I've recently started to use the Python adaptor within Teststand 2019 which seems to run well for the most part. I do however have an issue when making calls to a dll using the adaptor. This only happens when copying the same python adaptor step from another sequence. It hangs and will only work again if I load the dll call using the python adaptor from scratch. 

 

I have tried unloading the modules in the file menu and reloading the module in the adaptor configuration itself but this makes no difference. Are there any other steps I'm missing?

 

Thanks.

0 Kudos
Message 1 of 9
(4,206 Views)

Hi,

 

I was wondering if anyone has experienced this issue? Here are the steps usually taken

 

  1. Create a new sequence and add a python step using the adaptor.
  2. Point to python script in configuration
  3. Execute sequence - works fine
  4. Open an existing sequence which was previously created with a python script call
  5. Attempt to run sequence - fails to run
  6. Remove python step and re-add
  7. Attempt to run sequence again  - works fine#

I've tried the refresh option and have also selected the "Unload All Modules" option but this makes no difference.

Is there anything else I can try to save deleting and re-adding the python step to allow the sequence to run successfully?

 

Thanks.

0 Kudos
Message 2 of 9
(4,096 Views)

I am unable to reproduce the issue you are getting. Hence, requesting for more information.

 

In step 5, you mentioned that attempting to execute the sequence file will fail. Do you get any error? If yes, can you share the error message?

Can you also share a sample sequence file and python code module using which I can reproduce the error?

 

-Shashidhar

0 Kudos
Message 3 of 9
(4,079 Views)

Hi Shashidhar,

 

Thanks for your reply. I think this is a bit of a unique one to be honest. The sequence makes a call to a python function using the adaptor. The python function contains calls to a third party dll using a device which was developed in house. This was done using c types. This python function runs reliably when executed as a standalone function outside teststand using command line. 

 

After the function call, the third party device should transmit RF data and this is indicated by a green flashing led on the device. In this case when the sequence is loaded for the first time, this led does not flash correctly and so the sequence fails as no RF transmissions have been received by the other device. When I delete the python step, re-add and point to the python function, it runs fine and continues to do so unless I close that sequence and re-open it. 

 

I'm not sure that providing the contents of the sequence I have created will help with this one but sure let me know what you think.

 

Thanks.

0 Kudos
Message 4 of 9
(4,066 Views)

You can try debugging the python code module as mentioned here. You might get more information on what is happening when the tests are failing.

 

-Shashidhar

0 Kudos
Message 5 of 9
(4,060 Views)

Hi Shashidhar,

 

Thanks for that. I'll give that a go and see what it comes up with. I think that code needs a small change. A comma needs to be added before converting the getpid to str.

 

Thanks.

 

SLat105_0-1574258960759.png

0 Kudos
Message 6 of 9
(4,054 Views)

Hi Shashidhar,

 

So I've tried using the approach you suggested. I now see a different Process ID on different executions of the script. Is there anyway to understand what the Process ID relates to?

 

Thanks.

0 Kudos
Message 7 of 9
(4,052 Views)

Python scripts are executed in an external process as mentioned here. Hence, if you need to attach a python debugger, you should not attach it to the TestStand process and always attach it to the external process where the code is being executed. The process id mentions the id of the process where the script is being executed.

 

Lifetime of the external process which executes the python script is determined by "Python Interpreter to use" option existing in Python adapter settings or Advanced settings existing in the step. Meaning of different options for the setting is mentioned here.

 

So, if you configure the setting to be "Per Execution", a new Python interpreter session will be used (thereby using new external process) per execution of the client sequence file. Similarly, based on your settings, your script can be executed in an already existing Python interpreter session or might be executed in a different one. This might be one of the reason for getting different process id.

 

Also, if you use File >> Unload All Modules, all the existing Python Interpreter session will be destroyed and new ones will be created. This might be another reason why you are getting different process id.

 

-Shashidhar

0 Kudos
Message 8 of 9
(4,041 Views)

I have the same problem as already described, as soon as I redo my Python class call, the software works again. Load all modules does not change anything, that is very strange. Have you solved the problem?

0 Kudos
Message 9 of 9
(416 Views)