Perspective - Scripting - Runing scripts

8.1.5

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

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

I want to access by scripting ?

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.

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.

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:

1 Like

3 posts were split to a new topic: Dumping gateway threads