On Feb 5, 1:40 pm, Mike Orr <[email protected]> wrote:
> On Wed, Feb 4, 2009 at 6:02 PM, Matt Feifarek <[email protected]> wrote:
> > On Wed, Feb 4, 2009 at 3:10 PM, Mike Orr <[email protected]> wrote:
>
> >> You don't know when the user closes the browser.  In fact, you don't
> >> know anything after the user's last request, whether you will hear
> >> from them again or not.
>
> > Right, but I've always wanted this... although it is stateless, there is
> > still an event we can use.
>
> > The appserver knows when it cleans up or expires the session... couldn't we
> > do an event hook there, something like "on_expire()"?
>
> That would be useful for the case of sessions that have external
> resources to clean up.  I got a private question this week about
> having per-user SQLAlchemy engines.  Those can't be pickled so they
> can't be stored in the session, so I suggested putting a dict on
> pylons.app_globals for them, but again you have the problem of
> expiring them.
>
> Pylons/Paste doesn't have a cron scheduler to sweep through and expire
> old sessions, but maybe it's time we added that.  Or rather... it
> would only work with PasteHTTPServer.  mod_wsgidoesn't have a Python
> server process to trigger the events or run them in.

You could use WSGIDaemonProcess to create an additional daemon process
and then use WSGIImportScript to preload script that triggers
background thread to do any periodic processing. This daemon process
wouldn't be used to handle requests, just to do background stuff.

If only using a single process in daemon process group to handle
requests, you could always just run the background thread in it. You
only need a separate daemon process dedicated to it when using
embedded mode or daemon mode with multiple processes in daemon process
group.

I had started on a wiki document about doing just this sort of thing,
but only got it half way done. :-(

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to