473,466 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to handle lengthy operations?

Hi

I have a piece of code that can take a couple of minutes to run,
causing the browser to time out.

Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?

Thanks.
May 9 '07 #1
7 2131
At Thu, 10 May 2007 00:43:26 +0200, Gilles Ganault let his monkeys type:
Hi

I have a piece of code that can take a couple of minutes to run,
causing the browser to time out.

Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?

Thanks.
Are you sure it's not the server timing out? max_execution_time is a
setting in php.ini, defaults to 30 secs I believe.

You could, during processing, use ob_start() and ob_flush() to send some
stuff to the browser repeatedly.

Sh.
May 9 '07 #2
Gilles Ganault wrote:
Hi

I have a piece of code that can take a couple of minutes to run,
causing the browser to time out.

Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?

Thanks.
Hi Gilles,

here are two littels hints:

http://de2.php.net/ignore_user_abort
http://de3.php.net/set_time_limit
hth,
Roy
May 10 '07 #3
On 10 ÍÁÊ, 02:43, Gilles Ganault <nos...@nospam.comwrote:
Hi

I have a piece of code that can take a couple of minutes to run,
causing the browser to time out.

Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?

Thanks.
Try to use AJAX. Redirect user to "Please wait..." page which one will
check if operations are completed and make automatic redirect.

May 10 '07 #4
On May 9, 3:43 pm, Gilles Ganault <nos...@nospam.comwrote:
Hi

I have a piece of code that can take a couple of minutes to run,
causing the browser to time out.

Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?

Thanks.

What browser are you using and what is the code trying to do?

May 10 '07 #5
Gilles Ganault wrote:
Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?
Schraalhans Keukenmeester's point is an important one: the browser is not
the only thing with a timeout -- mod_php has its own timeout too.

Increase the max execution time as he said. To solve browser timeout
issues, slowly feed it some dummy data. Assuming that your script is
outputting HTML or XML, you could include something like this inside one
of your loops:

echo "<!-- x -->\n";

This assumes of course that you don't need to output any HTTP headers as
part of this long-running code, as body output obviously prevents the
header() function from working.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 10 '07 #6
C.
On 10 May, 20:46, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
Gilles Ganault wrote:
Is there a way to send empty, fake data to keep the browser happy
while the code is running on the server?

Schraalhans Keukenmeester's point is an important one: the browser is not
the only thing with a timeout -- mod_php has its own timeout too.
A better solution might be to run asynchronously in a seperate program
group (running something in the background of a webserver process is
not a good idea). It's quite easy on Linux/Unix:

$cmd='/path/to/php/script';

`at now php $cmd`;

I've heard that `start php $cmd` will give similar results on MS
platforms but you'd need to investigate further.

C.

May 11 '07 #7
On Thu, 10 May 2007 20:46:40 +0100, Toby A Inkster
<us**********@tobyinkster.co.ukwrote:
>This assumes of course that you don't need to output any HTTP headers as
part of this long-running code, as body output obviously prevents the
header() function from working.
Thank everyone for the tips!
May 12 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Howard | last post by:
Hi, I recently had a problem where I decided to store objects in a vector. (Previously, I had always stored pointers in vectors). Well, naturally, when storing an object in a vector, using...
7
by: Ioannis Vranos | last post by:
I have been checking C++/CLI lately by using VC++ 2005 Express Beta 1 (should be called Alpha though). In managed extensions we could pass managed pointers to functions taking unmanaged pointers...
6
by: Cerebrus99 | last post by:
Hi all, I'm making a Windows application that does some lengthy retrieval operations from a database and possibly from a internet resource. I want to show that the operation is going on, by...
1
by: MrNobody | last post by:
I'm going to be creating shapes in a OnPaint method of an extended Panel object, and I need mouse event functionality (onClick, onMouseOver) that kind of stuff... what's the best way to go about...
5
by: Jonah Bishop | last post by:
I'm developing a photo album web application for use on a web site, and I'm running into a problem with lengthy operations. My application allows the user to import a number of images at once into...
2
by: Gary Wessle | last post by:
Hi I need help organizing this program in the right way. I included the code below which compiles and runs and gives the desired effect to a certain point, but I don't know what the next step...
2
by: polocar | last post by:
Hi, suppose that you have a C# form with two buttons, that are the classical "btnOk" and "btnCancel" (besides them, of course in the form there can be many other controls). When the user clicks...
13
by: michael sorens | last post by:
I have a lengthy sequence of operations that are executed and reported on in a status window in a Windows Form application. Some work is done by background threads but other work is not. I am...
2
by: Dmitry Teslenko | last post by:
Hello! I'm using os.popen to perform lengthy operation such as building some project from source. It looks like this: def execute_and_save_output( command, out_file, err_file): import os ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.