RE: [PHP] Does PHP block requests?

2009-11-20 Thread Ford, Mike
> -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?

2009-11-20 Thread Peter Ford
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?

2009-11-20 Thread Ford, Mike
> -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