usleep() causing everything to "sleep"
I have two php scripts and when I call one that has 开发者_开发百科a loop with usleep() in it, it delays the execution of complete other script?
Any ideas why this would be?
Thanks!
You need to use session_write_close()
otherwise it stops all php in that session from running.
Is the usleep on the server? If yes, do you have sessions enabled? That might be whats blocking your scripts. When the first script opens up the session the other with the same session identifier cannot continue untill the first one closes it. That would explain why the second script resumes instantly after the first one dies
Try using two browsers. Or if you are using Chrome, try opening an Incognito instance to verify this. In your first script that has usleep(), your browser waits for a response. While your browser is waiting for this response, it puts your other request on hold so basically your other request hasn't reached the server yet.
So what you can do is open another browser (or the incognito window), and try loading the second script.
Both should load without waiting for each other.
精彩评论