My app is in Magento 2 and performing some long tasks from magento to shell. So in script execution time server is not serving to any other requests of that particular session until that task is getting finished and request completes. So i found that problem is with session lock and found solutions on php forums that using session_write_close() i can allow another requests of same session to perform their tasks.
But i don't know is it safe to do session_write_close().
NOTE: I don't need to write anything in session after closing it.
session_write_close has not one thing to do with request serving on the part of your server software. ALL it does is write the current session change to whatever storage method is being used to store $_SESSIONS.
Calling it will NOT have any impact on "other tasks" or release any execution back to the system. It's just a "save current $_SESSION values to file and prevent future changes to the file for this execution." -- NOTHING more, nothing less.
Has nothing to do with closing out the current "request", script execution time, or any other such nonsense.
j
stuff ;)
So if nothing breaks, and you don't need it. why should it be a bad practice?
php.net/manual/en/function.session-write-close.php
it's a concurrency safety mechanism. To me the question why you utilize the session if you don't need it is more immanent but that's something more of a framework / system architecture thing.
i guess.