Simple Example of Async working in a Perspective View Object

Hello. I’ve looked through the forums and I was unable to find a simple example of async code that would work in a perspective view object.

I even went as far as copying and pasting code from the later.py file but that also did not work.

May someone direct me to a concise, working example for a perspective view object class or suggest an alternative approach?

For reference, I am on Ignition Platform 8.1.48

I'm not sure what you mean by this.

What are you trying to accomplish, and why do you believe it needs to be asyncrhrous?

1 Like

Want to run a function async system.util.runAsynchronous is right there, but I agree with @lrose - I would not start making things async unless I had a reason too. IIRC too there is less reason to need async with perspective?

Currently the code is synchronously calling three api endpoints to then parse the large amount of data to then load it into a table. I would like to asynchronously call all three so processing time is reduced.

Do all your clients share this same data (or just filter it differently but otherwise rely on the same data)? If this is a case, have a gateway timer script (or a tag change script if there is an event style you know when you need to refresh from this API) do your call to the API’s, put it in a gateway tag. Then have your perspective table bind to this tag. You can filter between the gateway tag and table if needed with a transform or expressions if you use the Integration toolkit.

(post deleted by author)

Would this approach work for large amounts of data? How would parsing from the tags afterwards work? I ask this because all the data, after being received, has to be joined together to make the final output for the table.

This post might be useful - CompletableFuture is a layer above the raw threading you can do using invokeAsynchronous. I would endorse the advice to run this in a timer script or something similar.