Reputation: 88
HI I am using symfony2 to do some long API calls processing for example this call takes about 20 minutes to finish
$response = simplexml_load_file($apicall);
The problem is whenever I open any other action in another tab. It basically has to wait till the 20 minutes finish to load the result. I tried everything. I know this could be related to a session lock but I tried to close the session by using
$session = $this->get('session');
$session->save();
and also
session_write_close();
but nothing seems to work. I tried to close the session before the API call and after the API call. Does anyone know what should I do? It's been 2 days with this.
Upvotes: 1
Views: 918
Reputation: 10890
This is not specific to Symfony2
- this is just how php
and sessions work. To verify this you can try to call another action in private window or another browser (to be sure it's different session) while your long api call is still pending - this request should be handled without problems (if only CPU is free).
There are several ways to fix this, but as far as I know there's no quick and easy solution. What I would suggest is starting your long api call in another process (so it doesn't lock session) and do another action which will check if your original task is finished - if so, return the result.
You can check this for some inspiration
Note that closing session won't help you as on new request to server a new session is started.
Upvotes: 1