2 qq 22629997 qq_22629997 于 2017.09.19 15:10 提问

python threadpool 不能创建新线程的问题

你好 楼主关于threadpool的写法是这样的 ,然后楼主讲这个代码丢到了celery里面每分钟执行一次 每次执行大概4-5s的样子 但是跑一段时间就会报出can't start new thread 求大神告知是为什么

pool_cpu = threadpool.ThreadPool(30)
requests = threadpool.makeRequests(do_cpu_usage, cup_usage)
[pool_cpu.putRequest(req) for req in requests]

    pool_disk = threadpool.ThreadPool(30)
    requests = threadpool.makeRequests(do_disk_usage, disk_usage)
    [pool_disk.putRequest(req) for req in requests]

    pool_mem = threadpool.ThreadPool(30)
    requests = threadpool.makeRequests(do_mem_info, mem_info)
    [pool_mem.putRequest(req) for req in requests]

    pool_cpu.wait()
    pool_disk.wait()
    pool_mem.wait()

1个回答

oyljerry
oyljerry   Ds   Rxr 2017.09.19 17:19

用完了就结束掉,不然不停的占用系统资源

 pool.terminate()
Csdn user default icon
上传中...
上传图片
插入图片