LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Restart external application (Python)

Hi,

 

in my code I call Python for some calculations (in my real code I obviously do not use random numbers as input).

Problem is: My Python crashes due to external circumstances (which I haven't completely figured out yet). How can I check that my Python is still running and restart it, if it had crashed?

 

One idea I had was to get the boolean error state from the Python Node inside the While Loop (if there is an error due to Python crash, then there is an error present). But how would I use this information to restart my session?

 

Thank you for any advice

 

Martin

 

mw42_0-1606298906484.png

 

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

Hello Martin,

 

I think you will are with me that this is not a good idea.

But you can determine what kind of error you are getting when Python crashes and create proper error handling algorithm.

In case when you get that particular error you can recall Python from LabVIEW.

 

Don't you have memory leaks in Python?

__________________________________________
The best way to thank, is to give KUDOS
0 Kudos
Message 2 of 3
(1,034 Views)

Hi Martin,

 

As it seems you're hinting at, the best option is to try and avoid the crashing 🙂

 

But that aside, to restart your session in LabVIEW, you want to build a State Machine.

It might be easier to do this if you move the initial session opening inside the loop too - then you'll have something like this (perhaps, you could choose your states differently)...

Snippet - this can be dragged to a block diagram (search forums if you have trouble, they've been fiddly for a while).Snippet - this can be dragged to a block diagram (search forums if you have trouble, they've been fiddly for a while).

Other states:

cbutcher_0-1607235411505.png

 

If you use a Shift Register for the error wire, take care to take care of the error in the Restart Session case (because you'll end up there because there is an error... and propagating that to the Init/Calculate cases will prevent expected execution behaviour).

 


GCentral
0 Kudos
Message 3 of 3
(1,024 Views)