Avoiding the list comprehension would avoid the memory and overhead of making a new list.  Since it's only used used once the task_id attribute access could be on line 115.