Session errors

41 views
Skip to first unread message

NSC

unread,
Apr 12, 2012, 10:29:55 AM4/12/12
to web.py
Hi all, I've been working day and night to convert an asp.net app to
python using web.py. Things have been going great, but as the
application grows, I'm starting to see this error a lot:

File "/Library/Python/2.7/site-packages/web.py-0.36-py2.7.egg/web/
session.py", line 206, in decode
return pickle.loads(pickled)
BadPickleGet: 321660

It seems *something* is getting corrupted in the session? Once this
starts happening, the app is completely down until I manually delete
the files from the sessions directory.

I am keeping several large objects in the session, including one huge
xml configuration file. I need the session because reading it from
the disk for each request takes too long.

Here's my session setup line from my main class:
session = web.session.Session(app, web.session.DiskStore('sessions'))

I should also note that killing and restarting my process doesn't help
- once the session *file* is munged, nothing works until I delete it.

Anyone ever seen this behavior?
Thanks!
S

Dragan Espenschied

unread,
Apr 13, 2012, 11:20:09 AM4/13/12
to we...@googlegroups.com

Do not use file based sessions for large objects or anything where two or more
accesses to a session file could happen at the same time. File based sessions
are slow and race conditions seem to cause trouble all the time. Use a database
storage for your session data.

Bests,
Dragan

NSC

unread,
Apr 13, 2012, 11:53:47 AM4/13/12
to we...@googlegroups.com
Very good, and thanks for your response.  I do wonder, however, if the file session is slow and db is recommended, why I would bother with session at all.

The data I'm "caching" in the session actually lives in the database - I was trying to increase performance and the user experience by caching it.  (I'm coming from the .NET world, where server sessions are actually in memory, and really fast.)

I guess I need to rethink the whole process.

NSC

unread,
Apr 13, 2012, 11:57:38 AM4/13/12
to we...@googlegroups.com
Very good, and thanks for your response.  I do wonder, however - if the file session is slow and db is recommended, why I would bother with session at all?  The data I'm "caching" in the session actually lives in the database - I was trying to increase performance and the user experience by avoiding a database hit for this data on every request.

I'm coming from the .NET world, where server sessions are in memory and quite fast.  Seems like I need to rethink the whole process.

Thanks!
NSC


On Friday, April 13, 2012 11:20:09 AM UTC-4, drx wrote:

Dragan Espenschied

unread,
Apr 22, 2012, 3:04:27 PM4/22/12
to we...@googlegroups.com
Am 13.04.2012 17:53, schrieb NSC:
> Very good, and thanks for your response. I do wonder, however, if the file
> session is slow and db is recommended, why I would bother with session at all.
>
> The data I'm "caching" in the session actually lives in the database - I was
> trying to increase performance and the user experience by caching it. (I'm
> coming from the .NET world, where server sessions are actually in memory, and
> really fast.)
>
> I guess I need to rethink the whole process.

Sessions are storing data for a user of the system. A cookie is matched to a
pickled storage object entry in the database. If the database works well, it
will take care of the proper caching for data that is often requested.

I you want to cache something for all users, you might want to use it in a
global storage object inside your application?

Dragan

> On Friday, April 13, 2012 11:20:09 AM UTC-4, drx wrote:
>
> > Hi all, I've been working day and night to convert an asp.net
> <http://asp.net> app to
> > python using web.py. Things have been going great, but as the
> > application grows, I'm starting to see this error a lot:
> >
> > File "/Library/Python/2.7/site-packages/web.py-0.36-py2.7.egg/web/
> > session.py", line 206, in decode
> > return pickle.loads(pickled)
> > BadPickleGet: 321660
> >
> > It seems *something* is getting corrupted in the session? Once this
> > starts happening, the app is completely down until I manually delete
> > the files from the sessions directory.
> >
> > I am keeping several large objects in the session, including one huge
> > xml configuration file. I need the session because reading it from
> > the disk for each request takes too long.
> >
> > Here's my session setup line from my main class:
> > session = web.session.Session(app, web.session.DiskStore('sessions'))
> >
> > I should also note that killing and restarting my process doesn't help
> > - once the session *file* is munged, nothing works until I delete it.
> >
> > Anyone ever seen this behavior?
> > Thanks!
>
> Do not use file based sessions for large objects or anything where two or more
> accesses to a session file could happen at the same time. File based sessions
> are slow and race conditions seem to cause trouble all the time. Use a database
> storage for your session data.
>
> Bests,
> Dragan
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/webpy/-/wBz9v6cjmbIJ.
> To post to this group, send email to we...@googlegroups.com.
> To unsubscribe from this group, send email to webpy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webpy?hl=en.

--
http://noobz.cc/
http://digitalfolklore.org/
http://contemporary-home-computing.org/1tb/
Reply all
Reply to author
Forward
0 new messages