'read all pages'

def read_all_tasks_immediately(self, type_id):

    all_tasks = []
    page_size = self.page_size
    limit = self.limit
    if (limit and (limit < page_size)):
        page_size = limit
    first_page = self.read_task_page_info_by_page_index(type_id, 0, page_size)
    all_tasks.extend(first_page['tasks'])
    total_tasks = first_page['total_task_number']
    if (limit and (limit < total_tasks)):
        total_tasks = limit
    total_pages = (total_tasks / page_size)
    if ((total_tasks % page_size) != 0):
        total_pages += 1
    if (total_pages == 0):
        total_pages = 1
    for page_index in range(1, total_pages):
        current_page = self.read_task_page_info_by_page_index(type_id, 0, page_size)
        all_tasks.extend(current_page['tasks'])
    if limit:
        all_tasks = all_tasks[0:limit]
    for (i, task) in enumerate(all_tasks):
        task['#'] = i
    return all_tasks
