#NEWLINE# def handle_an_error( ) : #NEWLINE# #INDENT# 'Will be run if the async task raises an unhandled exception.' #NEWLINE# import os #NEWLINE# from furious.context import get_current_async #NEWLINE# async = get_current_async ( ) #NEWLINE# async_exception = async . result . payload #NEWLINE# exc_info = async_exception . traceback #NEWLINE# logging . info ( 'async job blew up, exception info: %r' , exc_info ) #NEWLINE# retries = int ( os . environ [ 'HTTP_X_APPENGINE_TASKRETRYCOUNT' ] ) #NEWLINE# if ( retries < 2 ) : #NEWLINE# #INDENT# raise Exception ( async_exception . error ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . info ( 'Caught too many errors, giving up now.' )