# Performing a perspective script action after X period of time

**URL:** <https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [April 30, 2024, 4:02pm UTC](https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715 "2024-04-30T16:02:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 30, 2024, 4:02pm UTC](https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715/1 "2024-04-30T16:02:21Z")

</div>

I need an element to show on screen for a period of time, and then optionally "timeout" and disappear.

I have all of the functionality in place, and It was working great.

Essentially I used @pturmel's `Later.py` script module (placed into `General.Later`) to make it happen with:

```python
def close_snack():
	self.custom.closeTrigger = True

timeout = int(value or 5000)
General.Later.invokeLater(close_snack, timeout)

```

However for some reason, that is no longer working and triggering the following exception in the logs:

```python
Execution rejected... running in calling thread [perspective-worker-45091] immediately. [org.python.proxies.Later$_runnable$399@56f2181c]

```

This causes the action to perform immediately, instead of waiting 5 seconds.

I looked at my commit history to see if anything has changed in this script, and nothing has changed... Any ideas?

---

<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:** [April 30, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715/2 "2024-04-30T16:04:40Z")

</div>

It means that the custom single-thread execution service that I create in gateway scope to emulate `invokeLater` is now broken. I'll have to investigate.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [April 30, 2024, 4:59pm UTC](https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715/3 "2024-04-30T16:59:08Z")

</div>

> [@kgamble](#):
>
> `Execution rejected... running in calling thread`

Update:

- Its actually really intermittent... after a while, I tested it out by switching to using `callAsyncDelayed` and it was totally fine.
- I have two different things leveraging this functionality at the same time? if thats possibly part of the cause?
- I am in version 8.1.36

---

<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:** [April 30, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715/4 "2024-04-30T17:37:00Z")

</div>

> [@kgamble](#):
>
> at the same time?

Maybe. It really is a single thread for the whole gateway.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [May 2, 2024, 9:31pm UTC](https://forum.inductiveautomation.com/t/performing-a-perspective-script-action-after-x-period-of-time/89715/5 "2024-05-02T21:31:24Z")

</div>

UPDATE:

I modified the project so I just trigger it the one time, so I isolated it so that its only being called one time in the whole project, and when I trigger that instance it will still evaluate instantly (sometimes).

Version is 8.1.36 as well if that info helps.
