Script php in java? run in the background

2

I have a question. I have a script that takes about 40 seconds to execute. I'm thinking then if I run on the android, the user is not willing to wait the 40 seconds, what happens he quits halfway through the application but the script runs or stops?

    
asked by anonymous 10.07.2015 / 13:01

1 answer

0

You can configure the PHP script to stop if the connection closes, by the ignore_user_abort () function. But the script also has to send data periodically (every few seconds) and call flush () because just sending data is that the lock is going to be detected. See the link link that has even examples.

But, in my opinion, it is a bad practice, to change the behavior of the server depending on the client to keep the connection open or not. Exactly what you are trying to avoid - a long or heavy processing, or a writing-like side effect in the database?

Some heavy operations like a SQL query that takes 40s (which should not be delayed in any way) will be executed atomically, ie you will not be able to interrupt it in the middle, even using the technique suggested in the first paragraph.

It would be nice to know more details of this processing; try to complement the question so we can complement the answer.

    
12.08.2015 / 07:02