Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 741

Show
Ignore:
Timestamp:
10/21/05 05:35:10
Author:
rdelon
Message:

Changing the default value for sessionFilter.locking from "implicit" to "explicit"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHANGELOG.txt

    r722 r741  
     12005-10-21: 
     2    * Changed the default value for sessionFilter.locking from "implicit" to "explicit" 
     3 
    142005-10-06: 
    25    * CherryPy-2.1.0-rc2 released 
  • trunk/cherrypy/lib/filter/sessionfilter.py

    r736 r741  
    104104        # Read config options 
    105105        sess.sessionTimeout = conf('sessionFilter.timeout', 60) 
    106         sess.sessionLocking = conf('sessionFilter.locking', 'implicit') 
     106        sess.sessionLocking = conf('sessionFilter.locking', 'explicit') 
    107107        sess.onCreateSession = conf('sessionFilter.onCreateSession', 
    108108                                    lambda data: None) 
  • trunk/docs/book/xml/sessions.xml

    r739 r741  
    171171    is serialized. This way, threads can't both modify the data at the same 
    172172    time and leave it in an inconsistent state.</para> 
    173     <para>By default, CherryPy will serialize access to the session data, so 
     173    <para>You can easily make CherryPy serialize access to the session data by setting the <option>sessionFilter.locking</option> config option to <literal>implicit</literal> (the default is <literal>explicit</literal>, which means that CherryPy won't do any locking for you). In the <literal>implicit</literal> mode, 
    174174    if a browser makes a second request while a first request is still being 
    175175    handled by the server, the second request will block while the first 
     
    177177    then the second request will be able to access it.</para> 
    178178    <para>This means that the second request will block until the first 
    179     request is finished. If you're using the <option>ram</option> backend, you 
    180     can manually shorten the window where the second request will block. This 
    181     is achieved by having the first request explicitly tell CherryPy when it 
    182     starts using the session data and when it is finished with it. In order to 
    183     do so, you have to call <literal>cherrypy.session.acquireLock</literal> 
    184     and <literal>cherrypy.session.releaseLock</literal>. You also have to set 
    185     the <literal>sessionFilter.locking</literal> config option to 
    186     <option>explicit</option>.</para> 
    187     <para>Note that this technique only works with the <option>ram</option> 
    188     backend. For other backends like <option>file</option> or 
    189     <option>postgresql</option>, it is not safe to release the session before 
    190     the request is finished, because the session data will only be saved at 
    191     the end of the request anyway. So it would be bad if some other thread 
    192     started accessing the data between the time when it is released and the 
    193     time when it is saved.</para> 
     179    request is finished.</para> 
    194180  </section> 
    195181  <section id="callbacks"> 

Hosted by WebFaction

Log in as guest/cpguest to create tickets