# How to interrupt script when the condition is false

**URL:** <https://forum.inductiveautomation.com/t/how-to-interrupt-script-when-the-condition-is-false/57147>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [March 13, 2022, 6:57pm UTC](https://forum.inductiveautomation.com/t/how-to-interrupt-script-when-the-condition-is-false/57147 "2022-03-13T18:57:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [March 14, 2022, 12:27pm UTC](https://forum.inductiveautomation.com/t/how-to-interrupt-script-when-the-condition-is-false/57147/2 "2022-03-14T12:27:17Z")

</div>

If I'm understanding your case correctly, this is might be because `time.sleep()` freezes the user interface for the duration of the delay. So when you set your condition to false elsewhere on the view it doesn't actually update the script until `sleep()` is done.

Regardless, using `time.sleep()` is incredibly bad practice for many reasons:

> [@Time.sleep function in Ignition](https://forum.inductiveautomation.com/t/time-sleep-function-in-ignition/10337/3):
>
> [quote=“dlaki”]Anyone here have tried to to use time.sleep function of time module in Ignition?[/quote]Nick hints at this, but let me be more explicit: Never, ever, use time.sleep or any other delay function in Ignition unless it is on its own asynchronous thread. Delays on the event dispatch thread (darn near everything in a client) will freeze the user interface for the duration of the delay. Just say no to any form of sleep. When you need delays, always use system.util.invokeLater() with …

> [@Perspective, time.sleep vs later.py](https://forum.inductiveautomation.com/t/perspective-time-sleep-vs-later-py/39955/2):
>
> time.sleep should be avoided in basically every scenario - the only exception I would maybe give is a dedicated thread spawned by invokeAsynchronous. later.py technically hooks into an internal class, but the signature of that class is pretty unlikely to change, and, crucially, it does not require a thread to be kept sleeping.

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-interrupt-script-when-the-condition-is-false/57147)._
