如何在python中使用threading.Semaphore和ThreadPoolExecutor

如何在python中使用threading.Semaphore和ThreadPoolExecutor,python,multithreading,concurrency,threadpoolexecutor,concurrent.futures,Python,Multithreading,Concurrency,Threadpoolexecutor,Concurrent.futures,我想知道如何在ThreadPoolExecutor 我的代码是这样的 def download_one(url): requests.get(url) ... ... ... return 'ok' def download_all(urls): with ThreadPoolExecutor(max_workers=7) as executor: return executor.map(download_one, urls, t

我想知道如何在
ThreadPoolExecutor
我的代码是这样的

def download_one(url):
    requests.get(url)
    ...
    ...
    ...
    return 'ok'

def download_all(urls):
    with ThreadPoolExecutor(max_workers=7) as executor:
        return executor.map(download_one, urls, timeout=20)

download_all(["url-1", "url-2"])
我的代码以这种方式工作得非常好 但我的问题是,我可能会使用不同的
URL多次调用
download\u all
函数 我的程序有一个更新,这些更新是
URL
,我想把它们转移到
download\u all
功能

但是,当我第一次调用
download\u all
函数时,我希望它能够工作 当我第二次叫它的时候,等它做完再重新开始

因此,在多次添加函数时,始终有
7个worker
正在运行,并且没有添加到
worker

以ThreadPoolExecutor(最大工作线程数=7)作为执行器: