[mod_python] For what session locking is? Do i need it while using MySQL?

Norman Tindall NormanTindall at zdisk.net
Fri Aug 11 03:23:36 EDT 2006


Hello Jim,

      Yesterday i realized what i saw in BaseSession class and i
      think it is terrible.

def lock(self):
     if self._lock:
         _apache._global_lock(self._req.server, self._sid)
         self._locked = 1
         self._req.register_cleanup(unlock_session_cleanup, self)

  Attention to last line of fuction "self._req.register_cleanup(unlock_session_cleanup, self)"
  so the unlock of session happens when last byte of a request sent to
  client and reqest object is to be destroyed.

  And what if i write in handler something like this:

  for x in range(100):
       time.sleep(1)
       req.write(str(x) +" "+ str(sess._locked)  + "<BR>",1)

  Session will be locked for a 100 seconds!
  Well there may be a blocking timeout but i don`n know how
  How parallel thread handle this situation with 100 sec session
  blocking.

  I think it SHOULD be added to documentation that after all
  manipulation with session data is made you MUST unlock it
  explicit.

  For example in my handler i can unlock even before headers is sent
  to client - and it is much more faster than 100 sec.




-- 
Best regards,
 Norman                            mailto:NormanTindall at zdisk.net



More information about the Mod_python mailing list