def execute_on_completion(application, config, callback):
 def inner(environ, start_response):
  try:
   result = application(environ, start_response)
  except:
   callback(environ)
   raise
  return generate_close_and_callback(result, callback, environ)
 return inner

def execute_on_completion ( application , config , callback ) : def inner ( environ , start_response ) : try : result = application ( environ , start_response ) except : callback ( environ ) raise return generate_close_and_callback ( result , callback , environ ) return inner
call callback once complete response is sent .