In a pylons controller, I would like to first return the response to the request (so that the user gets a response ASAP), and then perform some additional operations (say, updating view counts, etc.) that didn’t need to happen to generate the response. What’s the best-practice for doing things like this?
Thanks!
On most wsgi-based servers (like the standard wsgiref, nwsgi etc) there is a way to send some portion of a body out work a little more and send some more. I guess the “send some more” is optional.
Use yield instead of return. WSGI example (not sure if it translates well into Pylons):
Once the request handler runs out of code to run, it closes the connection.
Now, this is sure to work on standard wsgi servers I tried. I would like to hear if this works on Pylons.