RE: [PHP] Does PHP block requests?
> -Original Message- > From: Peter Ford [mailto:p...@justcroft.com] > Sent: 20 November 2009 16:40 > You're right about trying to use the same session - that was the > plan to get the > progress state passed across from one call to the other. > Closing the session on the generator script has the effect of > stopping any > further changes to the session variable, so I get the initial value > at each > request after that. Yes, that would be the expected effect of putting in a session_commit() at the beginning. > Perhaps I can do it with some other message passing mechanism (e.g. > a temporary > file) instead of the $_SESSION. Yes, that would be a way to go. Another alternative is to re-start the session each time you want to write an updated value into it and then immediately close it again. The cost of opening and closing a session to write a value into it compared to opening and closing a file to write a value into it may be a factor here, but I leave that comparison as an exercise for the reader. Others on the list may, of course, chip in with further options, or have other useful, or at least witty, comments. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
Re: [PHP] Does PHP block requests?
Ford, Mike wrote: >> -Original Message- >> From: Peter Ford [mailto:p...@justcroft.com] >> Sent: 20 November 2009 15:18 >> To: php-general@lists.php.net >> Subject: [PHP] Does PHP block requests? >> >> I have a tricky problem. >> >> I'm trying to make a progress feedback mechanism to keep users >> informed about a >> slowish process on the server end of a web app. The backend is >> generating a PDF >> file from a bunch of data which extends to many pages. I can keep >> tabs on the >> progress of this generation by working out how many lines of data is >> present, >> and how much of it has been processed. I use that information to set >> a session >> variable with a unique name - so for each step I set >> >> $_SESSION['some-unique- >> name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); > > The progress-counter Ajax script uses a session -- but does the PDF generator > use the same session? If so, I'm guessing you don't manually close the > session at any point and all the progress-checking calls are blocked until > the session auto-commits at the end of the generator script. To counter this, > you need to manually session_commit() somewhere near the beginning of the > generator script. > > Cheers! > > Mike > -- > You're right about trying to use the same session - that was the plan to get the progress state passed across from one call to the other. Closing the session on the generator script has the effect of stopping any further changes to the session variable, so I get the initial value at each request after that. I put together a simple "Generator" script to test this: 10,'count'=>0); for ($i=0; $i<10; $i++) { sleep(1); $_SESSION[$fcode]['count']++; } echo "Done"; ?> and the code for the progress backend is like this: http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Does PHP block requests?
> -Original Message- > From: Peter Ford [mailto:p...@justcroft.com] > Sent: 20 November 2009 15:18 > To: php-general@lists.php.net > Subject: [PHP] Does PHP block requests? > > I have a tricky problem. > > I'm trying to make a progress feedback mechanism to keep users > informed about a > slowish process on the server end of a web app. The backend is > generating a PDF > file from a bunch of data which extends to many pages. I can keep > tabs on the > progress of this generation by working out how many lines of data is > present, > and how much of it has been processed. I use that information to set > a session > variable with a unique name - so for each step I set > > $_SESSION['some-unique- > name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); The progress-counter Ajax script uses a session -- but does the PDF generator use the same session? If so, I'm guessing you don't manually close the session at any point and all the progress-checking calls are blocked until the session auto-commits at the end of the generator script. To counter this, you need to manually session_commit() somewhere near the beginning of the generator script. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
[PHP] Does PHP block requests?
I have a tricky problem. I'm trying to make a progress feedback mechanism to keep users informed about a slowish process on the server end of a web app. The backend is generating a PDF file from a bunch of data which extends to many pages. I can keep tabs on the progress of this generation by working out how many lines of data is present, and how much of it has been processed. I use that information to set a session variable with a unique name - so for each step I set $_SESSION['some-unique-name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); Now on the front end I'm doing an AJAX call to a script that just encodes this session variable into a JSON string and sends it back. The problem is that while the PDF is being generated, the AJAX calls to get the progress data (on a 1-second interval) are being blocked and I don't get why. The PDF generation is also triggered by an AJAX call to a script which generates the PDF in a given file location, then returns a URL to retrieve it with. So it appears that the problem is that I can't have two AJAX calls to different PHP scripts at the same time? WTF? Checking the requests with Wireshark confirms the the browser is certainly sending the progress calls while the original PDF call is waiting, so it's not the browser side that's the problem: and once the PDF call is finished the outstanding progress calls are all serviced (returning 100% completion of course - not much use!) Different browsers (Firefox, IE, Chrome at least) give the same result. For reference, the server is Apache 2.2.10 on a SuSE linux 11.1 box using mod_php5 and mpm_prefork - is that part of the problem, and is there an alternative? -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php