# Calling Gateway Script

**URL:** <https://forum.inductiveautomation.com/t/calling-gateway-script/33499>\
**Category:** General Discussion\
**Created:** [March 28, 2020, 3:28pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499 "2020-03-28T15:28:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NII](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nii/32/12920_2.png) [@NII](https://forum.inductiveautomation.com/u/NII)\
**Post date:** [March 28, 2020, 3:28pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499/1 "2020-03-28T15:28:30Z")

</div>

I have a few tags that have value-changed script and I’m calling a gateway script, call it ‘afunc’, in the value-changed script.

Would there be a problem if 2 or more tags call ‘afunc’ at the same time?

Does ignition support recursive or does it block further execution and wait until it exits currently running execution?

---

<div class="post-metadata">

**Author:** ![PRAMANJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pramanj/32/66935_2.png) [@PRAMANJ](https://forum.inductiveautomation.com/u/PRAMANJ)\
**Post date:** [March 28, 2020, 3:50pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499/2 "2020-03-28T15:50:34Z")

</div>

Events are queued and scripts are run one after other after completion of each execution

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2020, 4:34pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499/3 "2020-03-28T16:34:21Z")

</div>

This is true when it’s the same tag changing.

If multiple tags change but each of their tag scripts calls `afunc` then it will be potentially be executing simultaneously from up to 3 different threads. This is generally fine.

---

<div class="post-metadata">

**Author:** ![PRAMANJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pramanj/32/66935_2.png) [@PRAMANJ](https://forum.inductiveautomation.com/u/PRAMANJ)\
**Post date:** [March 28, 2020, 4:44pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499/4 "2020-03-28T16:44:07Z")

</div>

Oh, that's a learning for me! Thanks for the update. Does that mean all events are handled by separate threads? Quite possible in Java.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2020, 4:55pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499/5 "2020-03-28T16:55:35Z")

</div>

Tag scripts are executed on a fixed size (3) thread pool. Each tag has its own queue for script executions (default size 5) that it execute scripts on.

So for any given tag its tag script won’t ever be executing simultaneously, but other tag scripts might be.

---

<div class="post-metadata">

**Author:** ![PRAMANJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pramanj/32/66935_2.png) [@PRAMANJ](https://forum.inductiveautomation.com/u/PRAMANJ)\
**Post date:** [March 28, 2020, 5:03pm UTC](https://forum.inductiveautomation.com/t/calling-gateway-script/33499/6 "2020-03-28T17:03:02Z")

</div>

hmm.. pretty complex, but one should know this so that we don't get unexpected behavior from our scripts. I guess for client event scripts, handling may be different.
