Re: Behavior of the sleep function?

From: Date: Tue, 10 Mar 2015 21:35:33 +0000
Subject: Re: Behavior of the sleep function?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-324617@lists.php.net to get a copy of this message
On Mar 10, 2015, at 1:46 PM, Christoph Becker wrote:
Jeffry Killen wrote:
On Mar 10, 2015, at 11:40 AM, Christoph Becker wrote:
flock() implements *advisory* file locking, i.e. it works only if *all* file accesses use flock() to probe for a lock. So, basically, you have to call flock($_fw, LOCK_EX) also for $_GET['tstNo'] == '2'.
Thank you for the info: I am assuming that sleep uses output buffering, so it doesn't matter completely when it is called(?)
I probably don't understand your statement/question. Anyhow, sleep() simply pauses execution of the script, independently of output buffering. I just found <http://www.tuxradar.com/practicalphp/8/11/0>, where a very simplistic example of flock() in combination with sleep() is given. Please don't forget to "reply to all" next time.
O.K. I looked at the link and that is essentially what my code is trying to do: I.E. obtain a lock, print some text and then call sleep. But the text that is supposed to be returned before the call to sleep() doesn't show up until the first query is done, then the second query returns (with, as you indicated, adding a call to flock in the second query handling code.) That is why I presumed that sleep() was using output buffering. Anyhow, I am making progress. Thank you for your help JK

« previous php.general (#324617) next »