Thanks ;-)
On May 6, 10:21 am, Jorge Vargas <[email protected]> wrote:
> This is something the paste users may be interested in, so I'm CC that
> list. IMO that's an awful lot of work for such a simple feature.
>
> On Tue, May 5, 2009 at 2:53 PM, Bill5107 <[email protected]> wrote:
>
> > For my next attempt, I dug in to find out how to terminate the paster
> > server via Ctrl-C. Turns out there is a server flag to inidcate
> > terminating the server, the trick is how to get access to it. I
> > couldn't figure anything reasonable out so this is how I did it in the
> > end:
>
> > In my setup.py I made my own "paste.server_runner":
> > [paste.server_runner]
> > my_http = MyProj.lib.httpserver:server_runner
>
> > Then I wrote a replacement for the
> > ThreadPoolMixIn.process_request_in_thread so that I could set the
> > Paster shutdown flag if my TG2 app requested a shutdown. Then my
> > server_runner just needs to ensure my repalcement function is
> > installed before calling the paster-provideed server_runner. (my
> > process request replacement of course calls the original version as
> > well, it only sets the self.running state to false if my app requested
> > it)
>
> > i.e. something like this:
>
> > from paste.httpserver import server_runner as original_server_runner
>
> > my_app_running = True
> > original_process = None
>
> > def replacement_for_process_request_in_thread(self, request,
> > client_address):
> > original_process(self, request, client_address)
> > self.running &= my_app_running
>
> > def server_runner(*args, **kwargs):
> > if original_process is None:
> > original_process = ThreadPoolMixIn.process_request_in_thread
> > ThreadPoolMixIn.process_request_in_thread =
> > replacement_for_process_request_in_thread
> > return origianl_server_runner(*args, **kwargs)
>
> > Not very elegant but it seemed to do what I wanted in the moment. I
> > suppose this approach really becomes more of a Paster question and of
> > course only deals with the thread-pooled server, not to mention relies
> > on a module-level data item.
>
> > Still looking for better solutions if anyone has them :-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" 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/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---