Is a failing MATLAB license a try/catch exception?

Viewed 151

Sometimes I loose a toolbox license while running a MATLAB simulation taking several hours. The simulation then stops, I get an error message like:

  • License checkout failed
  • License Manager Error -5
  • Cannot find a license for Communication_Toolbox.

but there is no red error-text you normally get when there's an error in the MATLAB code itself.

Since this license error is not reproducable easily, does anybody know if it is an exception that can be caught within a try/catch? I could then maybe catch it, check the error-message for the word 'license' and keep trying until I get a license again and continue.

Edit: what apparently happens is that every couple of hours the flexlm license server is reset, if someone else then grabs a license before my already running script does, then my scrip is aborted. Or maybe my script tries to check the license while the license server is restarting...

1 Answers

OK, I just build the try/catch into the code and indeed the license error can be caught. The following represents a function which is called many times in my script and relies on several toolbox licenses. If a license is lost due to license server resets or some other reason, it waits for a minute and tries again. I don't care if the script has to wait an extra hour when running overnight...

function sim_data = get_sim_results(link, AWGN_SNR_dB)

while true
    try
        sim_data = get_sim_results_worker(link, AWGN_SNR_dB);
        break
    catch ME
        fprintf('Exception caught\n%s\n%s\n', ME.identifier, ME.message)
        pause(60)
    end
end
Related