Created
December 18, 2012 23:51
-
-
Save j00bar/4333196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WSGIApp(object): | |
POST_PROCESSING_TIMEOUT = 3 | |
def async_response_handler(self, request, response): | |
log.debug('Running async handler') | |
time.sleep(2) | |
log.debug('Finished async handler') | |
def __call__(self, environ, start_response): | |
# snip | |
log.debug('Dispatching post-response handlers...') | |
gevent.spawn( | |
lambda *args, **kwargs: gevent.with_timeout(self.POST_PROCESSING_TIMEOUT, | |
self.async_response_handler, *args, **kwargs), | |
request, response) | |
log.debug('Rendering response...') | |
return response(environ, start_response) | |
# log output reads.... | |
DEBUG:base:Dispatching post-response handlers... | |
DEBUG:base:Running async handler | |
DEBUG:base:Finished async handler | |
DEBUG:base:Rendering response... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment