I have a CherryPy app, for which I am using a PostgreSQL session. To be more exact, I modified a MySQL session class I found to work with PostgreSQL instead, and then I put this line in my code:
cherrypy.lib.sessions.PostgresqlSession = PostgreSQLSession And this works fine. One thing about its behavior is bugging me, however: accessing a page instantiates (and deletes) *many* instances of this class, all for the same session. Doing some debugging, I counted 21 calls to the __init__ function when loading a single page. Logging in and displaying the next page hit it an additional 8 times. My theory is that essentially every time I try to read from or write to the session, CherryPy is instantiating a new PostgreSQLSession object, performing the request, and deleting the session object. In that simple test, that means 29 connections to the database, 29 instantiations, etc - quite a bit of overhead, not to mention the load on my database server making/breaking those connections (although it handles it fine). Is this "normal" behavior? Or did I mess something up with my session class? I'm thinking that ideally CherryPy would only create one object - and therefore, one DB connection - for a given session, and then simply hold on to that object until that session expired. But perhaps not? ----------------------------------------------- Israel Brewster Systems Analyst II Ravn Alaska 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7293 ----------------------------------------------- -- https://mail.python.org/mailman/listinfo/python-list