zoukankan      html  css  js  c++  java
  • PHP

         之前写某些代码的时候,发现用户莫名奇妙地阻塞了,而且这种阻塞的情况还比较难以形容: 使用session过程中,在开启session后,同一浏览器,执行同一程序,不同页面会被锁。不同浏览器不会出现这种情况。

        (当时的情况是:需要执行一个非常长时间的脚本,我已经设置了用户断开不中断,无时间限制执行,但是最后发现执行这个脚本的时候,用户就不能访问其他页面了)

    其实最开始的时候,我并不知道是session 把它锁住了,查了半天手册才知道,看来真的是先天不足。

         在PHP BugList上面有人提到如下:  

    ------Calling session_start() appears to wait until other scripts have exited that are using the same session. My guess is the 1st request locks the session file <exclusive use, and the second request blocks until it 。

       PHP的官方回复是:

    Thank you for taking the time to write to us, but this is not a bug. This is expected.  The session file is locked to avoid corruption.

       其实对于这种问题是有一个解决办法

       session_write_close函数,write session data and end sesion。也就是自动放弃了session的锁,其他的脚本也就可以执行了。哎

  • 相关阅读:
    4.20 每日一练
    4.19 每日一练
    4.18 每日一练
    Python函数初
    Python的文件操作
    python购物车
    python深浅拷贝,集合以及数据类型的补充
    Python 代码块 小数据池
    Python字典
    Python 列表操作
  • 原文地址:https://www.cnblogs.com/maxmys/p/3327251.html
Copyright © 2011-2022 走看看