def FetchEntities(query_obj, limit):
  """Fetches number of Entities up to limit using query object.

  Args:
    query_obj: AppEngine Datastore Query Object.
    limit: Fetch limit on number of records you want to fetch.

  Returns:
    Fetched Entities.
  """
  entities = []
  # If Limit is more than 1000 than let's fetch more records using cursor.
  if limit > 1000:
    results = query_obj.fetch(1000)
    entities.extend(results)
    cursor = query_obj.cursor()
    while results and limit > len(entities):
      query_obj.with_cursor(cursor)
      results = query_obj.fetch(1000)
      entities.extend(results)
      cursor = query_obj.cursor()
  else:
    entities = query_obj.fetch(limit)
  return entities