#NEWLINE# def QueryAndOwn( self , queue , lease_seconds = 10 , limit = 1 ) : #NEWLINE# #INDENT# 'Returns a list of Tasks leased for a certain time.\n\n    Args:\n      queue: The queue to query from.\n      lease_seconds: The tasks will be leased for this long.\n      limit: Number of values to fetch.\n    Returns:\n        A list of GrrMessage() objects leased.\n    ' #NEWLINE# user = '' #NEWLINE# if self . token : #NEWLINE# #INDENT# user = self . token . username #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# res = self . data_store . RetryWrapper ( queue , self . _QueryAndOwn , lease_seconds = lease_seconds , limit = limit , token = self . token , user = user ) #NEWLINE# return res #NEWLINE# #UNINDENT# except data_store . TransactionError : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# except data_store . Error as e : #NEWLINE# #INDENT# logging . warning ( 'Datastore exception: %s' , res ) #NEWLINE# return [ ]