Error running function from system.util.invokeAsynchronous

Hello,

I’m a bit lost as to where this error is coming from. Seems like the invokeAsync is not liking something.

Thanks in advance!

INFO   | jvm 1    | 2019/07/29 14:03:03 | E [c.i.i.c.s.b.SystemUtilities   ] [22:03:03]: Error running function from system.util.invokeAsynchronous 
INFO   | jvm 1    | 2019/07/29 14:03:03 | com.inductiveautomation.ignition.common.script.JythonExecException: TypeError: 'NoneType' object is not callable
INFO   | jvm 1    | 2019/07/29 14:03:03 | 
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	at org.python.core.Py.TypeError(Py.java:235)
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	at org.python.core.PyObject.__call__(PyObject.java:316)
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	at org.python.core.PyObject.__call__(PyObject.java:357)
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:647)
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	at com.inductiveautomation.ignition.gateway.script.GatewaySystemUtilities$1.run(GatewaySystemUtilities.java:69)
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	at java.lang.Thread.run(Unknown Source)
INFO   | jvm 1    | 2019/07/29 14:03:03 | Caused by: org.python.core.PyException: TypeError: 'NoneType' object is not callable
INFO   | jvm 1    | 2019/07/29 14:03:03 | 
INFO   | jvm 1    | 2019/07/29 14:03:03 | 	... 6 common frames omitted

Can you post your code? You’re trying to run something that evaluates to null; it’s probably just a scoping issue.

I suspect it’s coming from a Gateway Timer Script?

By nature of invokeAsynchronous, it’s impossible to tell - all that stack trace is telling you is that there’s some issue with an attempt to invoke an asynch thread - specifically, the object being passed into system.util.invokeAsynchronous is null.

The end goal of this is to provide a summary of process activity after some period (overnight, weekly, etc.) so it was sending out an email for each process change. Possibly the whole thing should be re-worked to send only one email with a summary of all changes...

I got rid of the invokeAsynch. I was thinking the executeAndDistribute might need it to send multiple emails in a loop... Not sure.

The sendEmail function and new code (i.e. invokeAsynch) are within a for loop as mentioned in the post. Iterating through a SQL table for tank numbers & info.

for n in range(len(pyTankDS)):
    tankNo = pyTankDS[n][0]
	tank = 'Tank ' + tankNo

	#read relevant properties from tag path
	volume = str(round(system.tag.read('[default]Tank Status History/'+tank+'/Volume').value,1))
	
    def sendEmail(tankNo=tankNo, tank = tank, volume = volume):	
    	import system
    	recipients=["jane@test.com","jon@xyz.com"] #
	    system.report.executeAndDistribute(path="xyz", parameters = {"tankNumber":tankNo}, project="xyz", action= "email", actionSettings = {"to":recipients, "smtpServerName":"Mail Server", "from":"jon@xyz.com", "subject":tank + 'test email', "body":tank + " test " + volume})
    system.util.invokeAsynchronous(sendEmail)

print 'post-email function'
system.db.runUpdateQuery('DELETE FROM tank_fills')

Changed to:

for n in range(len(pyTankDS)):
    tankNo = pyTankDS[n][0]
	tank = 'Tank ' + tankNo

	#read relevant properties from tag path
	volume = str(round(system.tag.read('[default]Tank Status History/'+tank+'/Volume').value,1))

    recipients=["jane@test.com","jon@xyz.com"] 
    system.report.executeAndDistribute(path="xyz", parameters = {"tankNumber":tankNo}, project="xyz", action= "email", actionSettings = {"to":recipients, "smtpServerName":"Mail Server", "from":"jon@xyz.com", "subject":tank + 'test email', "body":tank + " test " + volume})

print 'post-email function'
system.db.runUpdateQuery('DELETE FROM tank_fills')

More info on this thread:

It seems the error was still coming up after I removed the invokeAsynchronous from the script.

Would it have tried to use invokeAsynchronous if it was a ‘dedicated’ thread? I switched it over to shared and will see if the error goes away.

Otherwise, I don’t see any other code that uses invokeAsynchronous. Maybe there is a scoping option somewhere else that has an invokeAsynchronous option, like an event script or such?

Thanks,

Michael