Martijn Geerts Posted January 3, 2016 Share Posted January 3, 2016 PHP writes its session data to a file by default, so does ProcessWire. So when ProcessWire starts executing a process the session starts and the session gets locked. After the process is completed the session unlocks and we are able to use ProcessWire again. For normal scripts this is oké. But when you have long running processes like importing big data or you want to create a responsive AJAX API, this can be a real bottleneck. You see this 'issue' for example with ImportPagesCSV where the admin 'freezes' while importing. 1 Dirty way to avoid session lock for big data import is to remove all sessions after you have started the import script. But this will log you out from the admin. An other way could be to use exec() and send the output to /dev/null. (Running the script in background) How do you guys deal with these session locks ? 1 Link to comment Share on other sites More sharing options...
Craig Posted January 3, 2016 Share Posted January 3, 2016 As a first step, you could try using the SessionHandlerDatabase module to see if that makes a difference. It's included in core, but not installed by default. 2 Link to comment Share on other sites More sharing options...
horst Posted January 4, 2016 Share Posted January 4, 2016 (edited) There is also an example layer class on SO that provides none blocking concurent session writes: http://stackoverflow.com/questions/10046570/php-save-session-when-using-session-write-close/27993746#27993746 But you need to implement this yourself before you start the long running tasks and switch back to PWs regular behave after you have finished them. You can use everything you want to handle sessions with http://php.net/manual/en/function.session-set-save-handler.php. Edited January 4, 2016 by horst 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now