Cancelling Running Loop

This is not the first time this happens. While running a for loop in the vision script, ignition freezes for a couple of minutes then shows a read timeout error. The problem is that the system shows that the loop is still running and the memory trend starts to fill out. I closed the designer and reopened it and it showed me that there is another user editing the same program, when I try to find that user and detect the overlap, it shows my name as the “other user”. The memory keeps filling up even after restarting designer and the user doesn’t really close!

Is there a way to abort all threads in a software?

This is bad programming. Event scripts run on the single GUI thread and must execute very quickly. A tenth of a second or less is a good, long-standing rule of thumb. If you have a script that is expected to take longer, particularly anything that includes a request across the network, you should use system.util.invokeAsynchronous() to place it in its own thread. There are restrictions on what such a background thread can do, though. You might find this topic helpful:

3 Likes

Thank you, however, I was running one of the manual examples with some minor modifications:

server = “Ignition OPC UA Server”
device = ‘[’+event.source.parent.getComponent(‘PLC OPC Name Text’).text+’]’
folderpath = ‘Devices/’+device
tags = system.opc.browse(opcServer=server, folderPath=folderpath)

for row in tags:
print row.getDisplayName()

We have many programs for each device and I wanted to see what names will it show.

OPC browse is notorious for long execution times. And in a Vision client, involves a network callout to the gateway. Not safe to run in a button event. Don’t do it.

1 Like

I can tell. Thanks again

1 Like