NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Python Script and Maintaining it in memory to interact

Hi all,

 

I'd like to get some ideas/help on the problem below.

 

I have a Python script that creates objects that allow to talk to some hardware through serial comms. And I can call this script from TestStand 4.2.1 using Call Executable step, which is good.

 

The problem is that after the script finishes and returns to TestStand, all objects created by the script is removed from memory. This means, next time I call this script again (to send a different command to hardware), all objects are recreated again. As the objects are big, it takes time, which become undesired overhead.

 

I was wondering if there is a way to call the script, then keep running in memory and move on to other steps. And when required to send another command, just interact with the script that's already running in memory. This way I could avoid the overhead of recreating the object again and again.

 

Thanks in advance.

 

Best regards,

Osman

 

0 Kudos
Message 1 of 3
(3,127 Views)

Hi,

 

I am not  fimilar with Python scripts, but you could launch you initial step in a new execution by placing the step a Sequence of its own then setting the SequenceCall step to run in a new execution and set it to not wait. If you pass the SequenceContext as well you could use a StationGlobal to pass data to and from this running object from your other steps.

 

Dont forget to stop your new execution before you end the main execution.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 3
(3,116 Views)

Osman -

 

Another option that might work for you is IronPython. If your scripts utilize a lot of the standard libraries, you'll probably need to check out IronClad. 

 

If you decide to look into this, please let us know if you are able to get it to work for you. We are planning to look into it some more on our side (beyond what we did for the KB), but haven't had a chance to do so yet. Any information you can provide (even it if just to let us know why this won't work for you) would be helpful.

 

 

David Rohacek

National Instruments

0 Kudos
Message 3 of 3
(3,093 Views)