How to interrupt script when the condition is false


I did make a simple countdown timer in the property of value on progress bar ,when a condition is true the timer start to count down to 0 and every is going good to here.

	import time
	if value :
	while value and tiempo>0:
		tiempo =tiempo -1
		time.sleep (1)
		self.props.value=tiempo #value property of progress bar
		if value==False or tiempo==0:
	return tiempo

I added an if condition to break the while condition , if I disable the condition intentionally. for 1 second the “if condition inside” of “while condition” break the countdown and the variable tiempo to 0
but the script still executing in the gateway where was the countdown and the progress bar still showing the number to the script finish , i can see this behavior in the diagnostics runing scripts.

the question is is there other way to make this?, can i interrupt the script like in the diagnostics script tab?


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: