#NEWLINE# def ExecuteQuery( self , query , args = None ) : #NEWLINE# #INDENT# 'Get connection from pool and execute query.' #NEWLINE# while True : #NEWLINE# #INDENT# connection = self . pool . GetConnection ( ) #NEWLINE# try : #NEWLINE# #INDENT# connection . cursor . execute ( query , args ) #NEWLINE# results = connection . cursor . fetchall ( ) #NEWLINE# self . pool . PutConnection ( connection ) #NEWLINE# return results #NEWLINE# #UNINDENT# except MySQLdb . Error as e : #NEWLINE# #INDENT# self . pool . DropConnection ( connection ) #NEWLINE# if ( "doesn't exist" in str ( e ) ) : #NEWLINE# #INDENT# raise e #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . warning ( 'Datastore query retrying after failed with %s.' , str ( e ) ) #NEWLINE# time . sleep ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# self . pool . connections . task_done ( )