Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
pause script.
Sonny Bama



Joined: 23 Jul 2005
Posts: 939

Posted: 11/20/10 04:53 
maybe I should go to the php forum with this.. but I figured one of you guys could help me with this.
Is there anyway to "pause" a php script. I am working on something that needs to stall the script for about 10 seconds before it does the next process. like so...

loop here {

doing stuff with images
}

sleep(10)

include (file)..

I need to include a file right after I do some things with the images.. the include file with echo the image, but if the GD stuff isnt done yet, then I just get the image code garble.. I need to make SURE the image is done before php includes the next file.. sleep() seems to make the whole script go to sleep (including the image stuff) I just need it to sit there and chill for a few seconds til it completes its task..

I thought about doing things to check the filesize, or file exists, but it wont exist yet and it will just die, or Ill have to check 10 times. lame!

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/21/10 15:09 
sleep() is the exact function you want Wink

http://php.net/sleep

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Sonny Bama



Joined: 23 Jul 2005
Posts: 939

Posted: 11/21/10 22:54 
thanks Kyle, but I guess what my confusion is, is its not clear to me weather sleep() continues its current actions while sleeping, or does it just pause doing everything? if it pauses scripting altogether then the file STILL wont be finished when it wakes up from sleeping.

Back to top
Brian
Jamroom Team


Joined: 09 Jul 2003
Posts: 37583
Location: Seattle, WA

Posted: 11/22/10 13:39 

Sonny Bama:
thanks Kyle, but I guess what my confusion is, is its not clear to me weather sleep() continues its current actions while sleeping, or does it just pause doing everything? if it pauses scripting altogether then the file STILL wont be finished when it wakes up from sleeping.


sleep() will STOP the script execution in that process, which based on your first post is what you want. Note that PHP is not asynchronous, so you will never still be "doing stuff with images" when you get to that include. Your loop will have exited.

- Brian


_________________
Make sure and check out:
* The Jamroom FAQ
* The Jamroom Documentation
Back to top
Sonny Bama



Joined: 23 Jul 2005
Posts: 939

Posted: 11/22/10 15:19 
I understand this.. but Im doing a file_get_contents, so I feel like php doesn't know if the file has succesfully finished downloading before ending the loop.

Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.