摘要:
import asyncio import random import threading from concurrent.futures import ThreadPoolExecutor import time def blocking_task(x): time.sleep(2) thread 阅读全文
摘要:
异步下载文件 async def download_file_with_curl(url: str, destination: str): curl_command = [ "curl", "-k", f"{url}", "-o", destination, ] process = await as 阅读全文
摘要:
线程池 都在一个进程内 GIL 不适合密集型计算 共享进程资源,存在不安全的线程 from concurrent.futures import ThreadPoolExecutor def task(n): return n * 2 if __name__ == '__main__': with T 阅读全文