How to disable sessioin cleanup thread

67 views
Skip to first unread message

Lukas Zapletal

unread,
Sep 8, 2008, 4:46:04 AM9/8/08
to cherrypy-users
Hello,

I have found that the GAE blocking is in session code - it starts new
thread
and this blocks Google App Engine. Is it possible to disable session
cleanup thread creation?

Thanks

LZ

Robert Brewer

unread,
Sep 8, 2008, 1:02:45 PM9/8/08
to cherryp...@googlegroups.com

You can hack around this by setting tools.sessions.clean_thread = True,
but it should probably have a more public way to do it. Care to open a
ticket?


Robert Brewer
fuma...@aminus.org

Lukas Zapletal

unread,
Sep 9, 2008, 3:33:15 AM9/9/08
to cherrypy-users
Thanks, I will do a ticket.

I am trying to implement GQL (Google App Engine) session
implementation that disables the thread. Are you accepting public
patches?

Is there some possibility to periodically call some function/method
for session cleanup (and to use wget to call this script every hour or
something)?

Thanks
> fuman...@aminus.org

Lukas Zapletal

unread,
Sep 9, 2008, 3:43:02 AM9/9/08
to cherrypy-users
http://www.cherrypy.org/ticket/854

LZ

On 8 Zář, 19:02, "Robert Brewer" <fuman...@aminus.org> wrote:
> fuman...@aminus.org

Robert Brewer

unread,
Sep 9, 2008, 11:16:48 AM9/9/08
to cherryp...@googlegroups.com
Lukas Zapletal wrote:
> I am trying to implement GQL (Google App Engine) session
> implementation that disables the thread. Are you accepting public
> patches?

With review, yes.

> Is there some possibility to periodically call some function/method
> for session cleanup (and to use wget to call this script every hour or
> something)?

That would be the clean_up thread which you just asked to remove. ;)

CherryPy was designed to work in environments where starting new threads
is allowed. If you're working in one where it isn't, then the only other
solution would be to rework cherrypy.engine to perform periodic tasks in
the main thread during its "wait" method. You can subclass
cherrypy.wspbus.Bus (overriding "wait") and give that a try. However,
keep in mind that the "wait" method is designed to be called for
purposes other than blocking the main thread--so perhaps "wait" needs to
change to wait(self, state, interval=0.1, callable=None), where
"callable" is a function to be called at each interval (i.e. every time
the sleep loop wakes up). Since the Bus is already a pub/sub engine,
maybe that should be wait(self, state, interval,
channel='main_thread_events'), and any code could subscribe a listener
to that channel.


Robert Brewer
fuma...@aminus.org

Lukas Zapletal

unread,
Sep 10, 2008, 11:21:56 AM9/10/08
to cherrypy-users
> > Is there some possibility to periodically call some function/method
> > for session cleanup (and to use wget to call this script every hour or
> > something)?
>
> That would be the clean_up thread which you just asked to remove. ;)

I meant if I will setup a daemon with wget calling some CGI script
every hour what code should I write to cleanup the session.

> CherryPy was designed to work in environments where starting new threads
> is allowed. If you're working in one where it isn't, then the only other
> solution would be to rework cherrypy.engine to perform periodic tasks in
> the main thread during its "wait" method. You can subclass
> cherrypy.wspbus.Bus (overriding "wait") and give that a try. However,
> keep in mind that the "wait" method is designed to be called for
> purposes other than blocking the main thread--so perhaps "wait" needs to
> change to wait(self, state, interval=0.1, callable=None), where
> "callable" is a function to be called at each interval (i.e. every time
> the sleep loop wakes up). Since the Bus is already a pub/sub engine,
> maybe that should be wait(self, state, interval,
> channel='main_thread_events'), and any code could subscribe a listener
> to that channel.

Bad news. Are there many threads in there? I think its not time to
hack cp kernel for me...

LZ

Robert Brewer

unread,
Sep 10, 2008, 4:34:49 PM9/10/08
to cherryp...@googlegroups.com
Lukas Zapletal wrote:
> > > Is there some possibility to periodically call some
function/method
> > > for session cleanup (and to use wget to call this script every
hour
> > > or something)?
> >
> > That would be the clean_up thread which you just asked to remove. ;)
>
> I meant if I will setup a daemon with wget calling some CGI script
> every hour what code should I write to cleanup the session.

Ah. I wasn't aware GAE allowed you to run other processes.
FileSession.clean_up is all the code you need to run to clean out
file-based sessions.


Robert Brewer
fuma...@aminus.org

Reply all
Reply to author
Forward
0 new messages