I am just wondering if it is ok to use the php sleep function in scripts? I have noticed that most examples found on this forum use timers to perform delays in actions. So is it ok to do something like this in an event handler:
sleep(60); //sleep for 1 minute
Or will this cause some malfunction in IPS?
This is a script I have written where the timer has no other function than to delay dimming of lights - the deley is set on the timer. Could I have used sleep instead with no penalty?
Using the sleep command will use 1 PHP thread during the sleep time. Having only 10 threads (default setting) available you will need to be sure that at no given time 10 scripts with delays will block all threads.
On the other hand you need to check the maximum execution time for PHP. Default is 150 seconds which you aren’t allowed to exceed.
Therefore it is common to use timer which are far more efficient and the better solution.
Thanks for your prompt reply, I was not aware of the thread limit.
Is the way I have done it in my example script the correct way to use timers? As you understand I am an IPS newbie and have been reading through heeps of examples on this forum. Unfortunatly I have no knowledge in german, so have to guess and trace the scripts to give them meaning.