# Can you put a time-out in a thread?

**URL:** <https://forum.inductiveautomation.com/t/can-you-put-a-time-out-in-a-thread/99260>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [November 29, 2024, 12:32pm UTC](https://forum.inductiveautomation.com/t/can-you-put-a-time-out-in-a-thread/99260 "2024-11-29T12:32:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [November 29, 2024, 12:32pm UTC](https://forum.inductiveautomation.com/t/can-you-put-a-time-out-in-a-thread/99260/1 "2024-11-29T12:32:31Z")

</div>

I'm invoking system.util.invokeAsynchronous and sometimes the scripts get stuck in loops or reexecuting (not wrong, could happend).

Can you put a timeout in threads, even if it's globally? and how?

Thanks!

---

<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:** [November 29, 2024, 2:26pm UTC](https://forum.inductiveautomation.com/t/can-you-put-a-time-out-in-a-thread/99260/2 "2024-11-29T14:26:57Z")

</div>

No, not safely. The closest you can get is to handle java interruptions, which produce exceptions in many OS operations. The interruption itself would be sent externally--another thread or some timer script would have to detect the overtime condition and send the interrupt.

Generally, though, write defensive code, with `try:` - `except:` blocks where needed, and use API calls that have timeouts.
