Doc #66769 [Com]: sleep function wrong definition
| From: | keithm at aoeex dot com | Date: | Wed, 26 Feb 2014 04:35:29 +0000 |
| Subject: | Doc #66769 [Com]: sleep function wrong definition | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11023@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66769&edit=1
ID: 66769
Comment by: keithm at aoeex dot com
Reported by: aryans dot vinay at gmail dot com
Summary: sleep function wrong definition
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Sleep does not block other instances of the script. Here's a snippet of ab output using your
test script:
---
Concurrency Level: 10
Time taken for tests: 4.246 seconds
Complete requests: 10
---
All 10 requests were completed in just 4.246 seconds.
You probably have some other element causing your scripts to depend on each other which is then
causing a sleep in one script to delay the others.
For example if your scripts all use sessions this can happen. With the default file-based sessions,
calling session_start() will lock the session file. Any other scripts trying to call session_start()
referencing that same file will block until the first script closes the file by either terminating
or calling session_write_close(). So calling sleep() in a script that is using the session would
cause other scripts to be delayed by the sleep duration due to the lock on the session file, not due
to how sleep() works.
Previous Comments:
------------------------------------------------------------------------
[2014-02-25 14:58:47] aryans dot vinay at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.sleep
---
This document describe sleep() as follow:
"Delays the program execution for the given number of seconds."
but problem is it actually delays execution of all the scripts running on the server.
so if we run the attached Test Script 10 times in parallel. it'll take 20 seconds to complete
all the requests. Please fix the words in documetation.
Thanks :)
Test script:
---------------
<?php
sleep(2);
echo "Hello";
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66769&edit=1