0

I want to create multiprocessing Python script, and i created that, but i have one idea for size Pool. I want to do multiprocessing so that when the CPU reaches 90% it reduces the size of the Pool.

I wached on google that Pool size not change.

How can i do this? Does anyone have an idea

Simple example by which i worked:

from multiprocessing import Pool

def f(x):
   return x*x

if __name__ == '__main__':
    with Pool(12) as p:
        print(p.map(f, range(10000000)))

Thanks all for answers!

Michael
  • 73
  • 7
  • Please share you code. – S.D. Sep 03 '20 at 18:07
  • I don't think you can have a dynamic pool-size. But you can create a pool-size tailor-made to the system: multiprocessing.cpu_size() will give you the number of cpu's. Use this for your pool size. – S.D. Sep 04 '20 at 10:36
  • duplicate of [Python multiprocessing pool: dynamically set number of processes during execution of tasks](https://stackoverflow.com/questions/49791077/python-multiprocessing-pool-dynamically-set-number-of-processes-during-executio) and [Dynamic pool size in multiprocessing?](https://stackoverflow.com/questions/41022342/dynamic-pool-size-in-multiprocessing) – milahu Jun 27 '22 at 16:03

0 Answers0