# system.util.invokeAsynchronous Error calling from Custom Method

**URL:** <https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 28, 2024, 7:51pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580 "2024-09-28T19:51:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [September 28, 2024, 7:51pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/1 "2024-09-28T19:51:19Z")

</div>

Can someone point out what am I doing wrong? -- Thanks

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/9353222f4629b97c9e22768f62e90c480ad8c332.png)

Error:

> **Error**
>
> com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 3, in func at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.getSession(AbstractScriptingFunctions.java:104) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:118) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:704) at jdk.internal.reflect.GeneratedMethodAccessor452.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.  
> at org.python.core.Py.JavaError(Py.java:545)  
> at org.python.core.Py.JavaError(Py.java:536)  
> at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:192)  
> at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. **call** (ScriptManager.java:553)  
> at org.python.core.PyObject. **call** (PyObject.java:461)  
> at org.python.core.PyObject. **call** (PyObject.java:465)  
> at org.python.pycode._pyx24743.func$2(:3)  
> at org.python.pycode.pyx24743.call\_function()  
> at org.python.core.PyTableCode.call(PyTableCode.java:173)  
> at org.python.core.PyBaseCode.call(PyBaseCode.java:306)  
> at org.python.core.PyFunction.function\_\_\_call_(PyFunction.java:474)  
> at org.python.core.PyFunction. **call** (PyFunction.java:469)  
> at org.python.core.PyFunction. **call** (PyFunction.java:464)  
> at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:847)  
> at com.inductiveautomation.ignition.gateway.script.GatewaySystemUtilities.lambda$\_invokeAsyncImpl$0(GatewaySystemUtilities.java:152)  
> at java.base/java.lang.Thread.run(Unknown Source)  
> Caused by: org.python.core.PyException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.  
> ... 16 common frames omitted  
> Caused by: java.lang.IllegalArgumentException: No perspective session attached to this thread.  
> at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.getSession(AbstractScriptingFunctions.java:104)  
> at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:118)  
> at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47)  
> at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.print(PerspectiveScriptingFunctions.java:704)  
> at jdk.internal.reflect.GeneratedMethodAccessor452.invoke(Unknown Source)  
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
> at java.base/java.lang.reflect.Method.invoke(Unknown Source)  
> at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:190)  
> ... 13 common frames omitted

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 28, 2024, 7:57pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/2 "2024-09-28T19:57:06Z")

</div>

Asynchronous threads are started without carrying the original thread's self-identifying locals. You must ensure you create the thread with default arguments to carry that information, or, with somewhat recent versions of Ignition, pass a Perspective component as a function argument.

---

<div class="post-metadata">

**Author:** ![Eugene49](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@Eugene49](https://forum.inductiveautomation.com/u/Eugene49)\
**Post date:** [September 28, 2024, 8:52pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/3 "2024-09-28T20:52:23Z")

</div>

I am stuck..  
What I am trying to do:  
When table has new row. I want the new row to be highlighted for 5 secs.  
So on the query code, I add wait 5 sec, and re execute the query.  
Not to create a bottle neck on the query code, I then planned to invokeAsynchronous the re-query.

edit: I think I should be able to implement this using `property change` script.  
Thanks.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 28, 2024, 9:35pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/4 "2024-09-28T21:35:03Z")

</div>

> [@pturmel](#):
>
> Asynchronous threads are started without carrying the original thread's self-identifying locals.

~~Tangent: this is fixed in 8.3.0.~~

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 28, 2024, 11:14pm UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/5 "2024-09-28T23:14:14Z")

</div>

> [@paul-griffith](#):
>
> fixed in 8.3.0

Not sure that won't backfire. Deliberate long-lived threads started by a UI will prevent memory reclaim for the session.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 29, 2024, 1:05am UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/6 "2024-09-29T01:05:24Z")

</div>

Fair point, but I err on the principle of least surprise. It's much easier to start your own thread than to carry your own script context over.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 29, 2024, 1:07am UTC](https://forum.inductiveautomation.com/t/system-util-invokeasynchronous-error-calling-from-custom-method/96580/7 "2024-09-29T01:07:16Z")

</div>

And actually, now that I think about it more, Perspective's specific context won't be carried over, only the general purpose platform level default DB, tag provider, etc. So it won't solve the issue described by the OP or risk memory "leaking".
