def _expiry_range_batched(session, upper_bound_func, batch_size):
 LOG.debug('Token expiration batch size: %d', batch_size)
 query = session.query(TokenModel.expires)
 query = query.filter((TokenModel.expires < upper_bound_func()))
 query = query.order_by(TokenModel.expires)
 query = query.offset((batch_size - 1))
 query = query.limit(1)
 while True:
  try:
   next_expiration = query.one()[0]
  except sql.NotFound:
   break
  (yield next_expiration)
 (yield upper_bound_func())

def _expiry_range_batched ( session , upper_bound_func , batch_size ) : LOG . debug ( 'Token expiration batch size: %d' , batch_size ) query = session . query ( TokenModel . expires ) query = query . filter ( ( TokenModel . expires < upper_bound_func ( ) ) ) query = query . order_by ( TokenModel . expires ) query = query . offset ( ( batch_size - 1 ) ) query = query . limit ( 1 ) while True : try : next_expiration = query . one ( ) [ 0 ] except sql . NotFound : break ( yield next_expiration ) ( yield upper_bound_func ( ) )
return the stop point of the next batch for expiration .