The problem with this approach is that long-running post-request processing will delay the response.
If you put a 10 second sleep in your "finally" block then the response to the user will be delayed by 10 seconds. I use workerpool. I create a global workerpool instance for my controller, then submit post-processing jobs to the pool. Submitting the job to the pool takes essentially no time at all -- and the request thread can then go about writing its response to the client. The post-processing, since it's running in the background, does not hold up the response to the client. Also, having a long-running post-processing task in the main request thread means the thread is tied up and can't handle new requests. By moving the post-processing into a backgroun thread, the request thread not only responds faster to the client, but it also becomes available for handing the next incoming request sooner. On 21 Okt., 05:46, Stéphane Klein <[email protected]> wrote: > class BaseController(WSGIController): > > ... > > def __call__(self, environ, start_response): > """Invoke the Controller""" > # WSGIController.__call__ dispatches to the Controller method > # the request is routed to. This routing information is > # available in environ['pylons.routes_dict'] > > try: > return WSGIController.__call__(self, environ, start_response) > finally: > print('Foobar') > meta.Session.remove() > > Here, "Foobar" is printed in console after all request. > > Regards, > Stephane > -- > St phane Klein <[email protected]> - French > blog:http://stephane-klein.info > twitter:http://twitter.com/klein_stephane > pro:http://www.is-webdesign.com -- 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.
