# Perspective - Scripting - Runing scripts

**URL:** <https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [June 9, 2021, 2:55pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599 "2021-06-09T14:55:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [June 9, 2021, 2:55pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599/1 "2021-06-09T14:55:54Z")

</div>

8.1.5

Is there a way to valid if a srcipt is currently running ?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 11, 2021, 10:58am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599/2 "2021-06-11T10:58:57Z")

</div>

There’s a section in the status page of the gateway webserver that shows running scripts. I’ve never actually used it before…

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [June 11, 2021, 1:53pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599/3 "2021-06-11T13:53:21Z")

</div>

I want to access by scripting ?

---

<div class="post-metadata">

**Author:** ![rbachman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbachman/32/43718_2.png) [@rbachman](https://forum.inductiveautomation.com/u/rbachman)\
**Post date:** [December 7, 2021, 10:33pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599/4 "2021-12-07T22:33:12Z")

</div>

I have this same request. I’m familiar with the **Running Scripts** section in the gateway, but I’m trying to identify a way to prevent the same script from running more than 1 time on the Gateway at the same time. For example, we may have a long-running Gateway script that is on a timer. If I save the project where the Gateway Event is running on _while_ the script is running, the Gateway will open the script again on a separate thread.

The attached screen shot shows an example of this situation I was able to create during testing.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/8/d85b81f7443b152494e47c12392ca7974512e9f0.png)

Also, in case anyone is interested, the issue is that we have certain data that must be precisely sequenced. If we have the script running in more than one thread, then _ **both** _ threads will attempt to sequence the data, and this generally creates duplicates.

I have a workaround where the first instance of the script turns on a memory tag so that other instances of the script “know” that the script is already running, but I’ve run into issues in the past where that tag got left on because the script exited due to an error. That prevents the script from running at all. I’m just curious if there is a more elegant way to handle this.

---

<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:** [December 7, 2021, 11:48pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599/5 "2021-12-07T23:48:50Z")

</div>

I'd place a python lock object in persistent memory (system.util.getGlobals() or my own system.util.persistent()) using .setdefault() to never replace it. See my suggestion over in this topic:

> [@Global objects in Perspective Scope](https://forum.inductiveautomation.com/t/global-objects-in-perspective-scope/53688/13):
>
> Replace it unconditionally in the top level of the defining script. Something like this: class myClass(): \_\_init\_\_(self, prior): # Copy important values from prior version, as long as they # are platform data types. Stop any threads stored in prior # and remove any of its listeners from the platform. pass # Get the persistent global dictionary \_g = system.util.getGlobals() # Protect the swap with a lock. Locks are defined by # the jython stdlib, so do not have to be replaced on re…

---

<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:** [January 28, 2022, 6:49pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-runing-scripts/47599/6 "2022-01-28T18:49:58Z")

</div>

3 posts were split to a new topic: [Dumping gateway threads](https://forum.inductiveautomation.com/t/dumping-gateway-threads/55501)
