how to start thread by group?

oyster lepto.python at gmail.com
Mon Oct 6 15:24:10 CEST 2008


my code is not right, can sb give me a hand? thanx

for example, I have 1000 urls to be downloaded, but only 5 thread at one time
def threadTask(ulr):
  download(url)

threadsAll=[]
for url in all_url:
     task=threading.Thread(target=threadTask, args=[url])
     threadsAll.append(task)

for every5task in groupcount(threadsAll,5):
    for everytask in every5task:
        everytask.start()

    for everytask in every5task:
        everytask.join()

    for everytask in every5task:        #this does not run ok
        while everytask.isAlive():
            pass



More information about the Python-list mailing list