On Fri, May 24, 2019 at 10:48 AM MRAB <pyt...@mrabarnett.plus.com> wrote: > > On 2019-05-24 01:22, Chris Angelico wrote: > > What I'd recommend is a thread pool. Broadly speaking, it would look > > something like this: > > > > jobs = [...] > > > > def run_jobs(): > > while jobs: > > try: job = jobs.pop() > > except IndexError: break # deal with race > > > Personally, I'd use a queue (from the 'queue' module), instead of a > list, for the job pool.
It's not going to be materially different, since there's nothing adding more jobs part way. Either way works, and for the sake of a simple demo, I stuck to a core data type that any Python programmer will know, rather than potentially introducing another module :) But yes, the queue is a common choice here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list