Running background processes - Accessing same script twice

3

I have a PHP script that aims to integrate with a third-party system.

Basically, my script sends image and text files to the client ftp.

To ensure processing for a long time, I use the following statement:

ignore_user_abort( true ); // Não interrompe o script em caso de perda de conexão
set_time_limit( 21600 ); // Time out após 6h

Also, to prevent double processing, a file that is deleted at the end of the script is created at the beginning.

So, if the file exists, it is because the process is running.

The script works beautifully.

The problem lies in the fact that this script is called via AJAX by my system (asynchronously), and is then run in the background. But then, once I start the process, I can not do anything else on the system until it ends, unless I open another browser or use another protocol (one with www and another without).

Is this browser limitation, or is it something that can be configured on the server / php?

Thanks for the help!

Obs. : There are several processes running in the background in the system, but this is the only one that blocks other processes.

    
asked by anonymous 15.08.2014 / 22:26

1 answer

3

Okay, thank you for the time you gave me helping (especially @Sergio), but I found the solution.

The problem is in a simple error. I've done it before, but it's been a long time ... I just remembered and I really figured it was this:

I open a session at the beginning of the process (with session_start() , of course) but not close at any time (with session_write_close() ).

It's not about shutting down or destroying the session. It's just a matter of telling the script that you no longer need it after a certain point.

Once you've placed session_write_close() right after the last session, the problem no longer occurs.

Thanks again!

    
15.08.2014 / 22:49