# How to trigger a gateway timer to trigger immediately but no more than four times per minute?

**URL:** <https://forum.inductiveautomation.com/t/how-to-trigger-a-gateway-timer-to-trigger-immediately-but-no-more-than-four-times-per-minute/75476>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [June 23, 2023, 8:08pm UTC](https://forum.inductiveautomation.com/t/how-to-trigger-a-gateway-timer-to-trigger-immediately-but-no-more-than-four-times-per-minute/75476 "2023-06-23T20:08:47Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [June 23, 2023, 9:06pm UTC](https://forum.inductiveautomation.com/t/how-to-trigger-a-gateway-timer-to-trigger-immediately-but-no-more-than-four-times-per-minute/75476/7 "2023-06-23T21:06:43Z")

</div>

I usually use this construct at the top level of a script module:

```auto
from java.util.concurrent import LinkedBlockingDeque, TimeUnit

# Capacity = 100. The new instance is thrown away if already in globals.
deque = system.util.getGlobals().setdefault('MySpecialForeverQueue', LinkedBlockingDeque(100))

def someTimerEvent(event):
	next = deque.poll(15000, TimeUnit.MILLISECONDS)
	if next:
		# handle it
# Run the above at a fixed **rate** matching the poll timeout.

```

Use [ConcurrentLinkedDeque](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ConcurrentLinkedDeque.html) if you don't want any capacity. (It'll run a bit faster that a `LinkedBlockingDeque` that doesn't have a limit, IIRC.)

Queues are a bit faster than Deques, if you don't need bidirectional traffic.

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-trigger-a-gateway-timer-to-trigger-immediately-but-no-more-than-four-times-per-minute/75476)._
