AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'invokeLater'

Good afternoon.

In Ignition 8.0.14, when I try to use the “system.util.invokeLater ()” function in a Gateway Event Script (tag change), this error is logged in the logs:

This is the code:

def runThisLater():
	import system		
	Logger_Script = system.util.getLogger("probar")"hola")		    

system.util.invokeLater(runThisLater, 3000)

Best Regards.

invokeLater is only available when code is executing in client/designer scope. If you understand what it’s actually doing - running some piece of code later on the Swing Event Dispatch Thread, then it should be obvious why.

Perhaps you are misusing/abusing invokeLater?

I think your answer is very hasty. According to the documentation: “The Threading Library has a Timer function that works in a very similar fashion to invokeLater.”

“Timer” does work in Gateway Events Script, so I thought “invokeLater” would work too.

When a tag changes, I need to execute a function after a few seconds, that’s why “invokeLater” seemed correct to me.
I understand that I have to use “Timer”.

Best Regards.

1 Like

@pturmel has a implementation here on the forums that uses an (internal) class to allow for the ‘delayed execution’ functionality of invokeLater to work on the gateway.

And what do you think about python’s Timer object?

Thank you.

Bleh, I wish the training team hadn’t written those docs advocating the use of invokeLater as a convenient way to introduce a delay. That’s really not what it’s for.

Jython’s Timer seems fine, but it’s conceptually no different than just using invokeAsync and then sleeping as the first thing you do for the amount of delay you desire. Both end up using a dedicated Thread.


Thank you.