Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7981

Re: threading : make stop the caller

From Terry Reedy <tjreedy@udel.edu>
Subject Re: threading : make stop the caller
Date 2011-06-19 12:38 -0400
References <itl1sc$ap0$1@news.univ-fcomte.fr> <mailman.155.1308496777.1164.python-list@python.org> <itl56g$aut$1@news.univ-fcomte.fr>
Newsgroups comp.lang.python
Message-ID <mailman.160.1308501519.1164.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

threading : make stop the caller Laurent Claessens <moky.math@gmail.com> - 2011-06-19 16:42 +0200
  Re: threading : make stop the caller Chris Angelico <rosuav@gmail.com> - 2011-06-20 01:19 +1000
    Re: threading : make stop the caller Laurent Claessens <moky.math@gmail.com> - 2011-06-19 17:39 +0200
      Re: threading : make stop the caller Laurent Claessens <moky.math@gmail.com> - 2011-06-19 17:54 +0200
      Re: threading : make stop the caller Chris Angelico <rosuav@gmail.com> - 2011-06-20 02:03 +1000
        Re: threading : make stop the caller Laurent Claessens <moky.math@gmail.com> - 2011-06-19 18:08 +0200
      Re: threading : make stop the caller Terry Reedy <tjreedy@udel.edu> - 2011-06-19 12:38 -0400
        Re: threading : make stop the caller Laurent Claessens <moky.math@gmail.com> - 2011-06-19 18:52 +0200
          Re: threading : make stop the caller Lie Ryan <lie.1296@gmail.com> - 2011-06-20 03:04 +1000
      Re: threading : make stop the caller Terry Reedy <tjreedy@udel.edu> - 2011-06-19 12:58 -0400

csiph-web