dundeemt | 25 Nov 14:39

ThreadManager and subscribing


I am confused as to the proper way to handle subscribing to threads in
embedded mode.

If running standalone CP, then you should subscribe to start_thread/
stop_thread, correct?

But if you are running under Apache you should subscribe to
acquire_thread and ?stop_thread?

from the ThreadManager docstring:
If threads are created and destroyed by code you do not control

    (e.g., Apache), then, at the beginning of every HTTP request,

    publish to 'acquire_thread' only. You should not publish to

    'release_thread' in this case, since you do not know whether

    the thread will be re-used or not. The bus will call

    'stop_thread' listeners for you when it stops.

-Jeff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
(Continue reading)

Robert Brewer | 27 Nov 17:50
Favicon
Gravatar

Re: ThreadManager and subscribing


dundeemt wrote:
> I am confused as to the proper way to handle subscribing to threads in
> embedded mode.
> 
> If running standalone CP, then you should subscribe to start_thread/
> stop_thread, correct?
> 
> But if you are running under Apache you should subscribe to
> acquire_thread and ?stop_thread?
> 
> from the ThreadManager docstring:
> If threads are created and destroyed by code you do not control
> 
>     (e.g., Apache), then, at the beginning of every HTTP request,
> 
>     publish to 'acquire_thread' only. You should not publish to
> 
>     'release_thread' in this case, since you do not know whether
> 
>     the thread will be re-used or not. The bus will call
> 
>     'stop_thread' listeners for you when it stops.

That docstring is mostly for server code, not your app code. Note that
it talks about when to *publish*, not when to subscribe. And indeed,
cherrypy.Application publishes to 'acquire_thread' for you on every
request, so you don't have to worry about that.

When CP does publish to 'acquire_thread', then
(Continue reading)


Gmane