Re: Session file locking not working properly in multithreaded environment
Ralph Heinkel <ralph.heinkel-S0/[email protected]> Fri, 10 May 2019 11:22:04 -0700 (PDT)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_392_723636250.1557512525141 Content-Type: multipart/alternative; boundary="----=_Part_393_897432824.1557512525141" ------=_Part_393_897432824.1557512525141 Content-Type: text/plain; charset="UTF-8" On Friday, 10 May 2019 19:31:28 UTC+2, Tim Roberts wrote: > > > The zc.lockfile I'm looking at certainly opens a new fd each time, but > the source I'm looking at doesn't have a UnixLockFile class, as your log > shows. > > Your log shows to calls to _lock_file, but it doesn't show that the both > succeed. Do they? > > > yes, both succeed. The log I showed was truncated a little bit too early. Both threads then worked on the same session file simultaneously, resulting in the described behavior that one thread reads incomplete data from the session file because the other thread hasn't finished yet writing to it. As I said I was still working on cherrypy 15. And you are right, in the most current cherrypy version zc.lockfile.LockFile() is used. However I run into the same problems with cherrypy 18. That is probably due to the fact that "The zc.lockfile package provides a basic portable implementation of *interprocess* locks using lock files" as its project description states. Since in most cases people run cherrypy with multiple threads we might need to think about a locking implementation that also supports inter-thread locking of a file. Otherwise IMO the locking for file sessions only makes half sense. -- You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at https://groups.google.com/group/cherrypy-users. To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/14769e69-3b9b-4e73-917a-8ab0a4ee754e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_393_897432824.1557512525141 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">On Friday, 10 May 2019 19:31:28 UTC+2, Tim Roberts wrote:= <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor= der-left: 1px #ccc solid;padding-left: 1ex;"><br>The zc.lockfile I'm lo= oking at certainly opens a new fd each time, but=20 <br>the source I'm looking at doesn't have a UnixLockFile class, as= your log=20 <br>shows. <br> <br>Your log shows to calls to _lock_file, but it doesn't show that the= both=20 <br>succeed.=C2=A0 Do they? <br> <br> <br></blockquote><div><p>yes, both succeed. The log I showed was truncated = a little bit too early. Both threads then worked on the same session file simultaneously, resulting in the described behavior that one thread reads incomplete data from the session file because the other thread hasn't finished yet writing to it.</p><p><br> </p> <p>As I said I was still working on cherrypy 15. And you are right, in the most current cherrypy version zc.lockfile.LockFile() is used. However I run into the same problems with cherrypy 18. That is probably due to the fact that "The zc.lockfile package provid= es a basic portable implementation of <b>interprocess</b> locks using lock files" as its project description states. <br></p><p><br> </p> <p>Since in most cases people run cherrypy with multiple threads we might need to think about a locking implementation that also supports inter-thread locking of a file. Otherwise IMO the locking for file sessions only makes half sense.</p>=C2=A0</div></div> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;cherrypy-users" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:cherrypy-users+unsubscribe-/[email protected]">cher= rypy-users+unsubscribe-/[email protected]</a>.<br /> To post to this group, send email to <a href=3D"mailto:cherrypy-users@googl= egroups.com">cherrypy-users-/[email protected]</a>.<br /> Visit this group at <a href=3D"https://groups.google.com/group/cherrypy-use= rs">https://groups.google.com/group/cherrypy-users</a>.<br /> To view this discussion on the web visit <a href=3D"https://groups.google.c= om/d/msgid/cherrypy-users/14769e69-3b9b-4e73-917a-8ab0a4ee754e%40googlegrou= ps.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/= msgid/cherrypy-users/14769e69-3b9b-4e73-917a-8ab0a4ee754e%40googlegroups.co= m</a>.<br /> For more options, visit <a href=3D"https://groups.google.com/d/optout">http= s://groups.google.com/d/optout</a>.<br /> ------=_Part_393_897432824.1557512525141-- ------=_Part_392_723636250.1557512525141--