11-25-2020 04:15 AM
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
12-05-2020 03:53 PM
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?
12-06-2020 12:17 AM - edited 12-06-2020 12:19 AM
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)...
Other states:
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).