threading : make stop the caller

Terry Reedy tjreedy at udel.edu
Sun Jun 19 12:38:26 EDT 2011


On 6/19/2011 11:39 AM, Laurent Claessens wrote:

> In the same time I've a thread that read the list and perform the
> operations:
>
> def run():
> while task_list :
> task = task_list[0]
> task_list.remove(task)
> task.start()

Popping task off the end of the list is more efficient:

while task_list:
   task_list.pop().start()

or if the list is static

for task in task_list:
   task.start()


-- 
Terry Jan Reedy




More information about the Python-list mailing list