Hello members,

I am using system.util.invokeAsynchronous for running certain functions and it is called from Gateway Timer script

For example
system.util.invokeAsynchronous(longProcess, [arg1,arg2])

In this case if there's an error within longprocess, then it is not notified in the Ignition Gateway's Status > Gateway Scripts > Timer section. Instead it always displays success (refer screenshot below).

If there is an error in the longprocess function it is notified in the Status > error log section only as shown below.

So my question is, if we use invoke asynchronous how to capture the error in the function which is called within it.I tried calling invoke asynchronous within try except to capture error using logger, but it doesn't capture the error. But if i call the function without invoke asynchronous then try except captures the error.

thanks in advance for your support.

You are asking for the impossible. An asynchronous call runs on a completely new, separate thread, and the original caller continues running before the asynchronous function even gets started. If you try to make the caller wait for any exceptions, you might as well not use asynchronous at all.


Hi Pturmel, Thank you for the response.

I understood your point. But in general, if have a long function which takes some seconds to complete and if I use invoke asynchronous it is called in separate thread and it there's an error for any reason, so it would be recorded only in error logs. Is that right? or should I follow any procedure for exception handling while using invoke asynchronous?

Such errors should be reported in your gateway log, yes. But in some cases, only once. I generally use my own exception handling and customized logging.