How to get full CPU processes and threads

I’ve been testing full processing capabilities. Server has 40 cores and 80 threads w 96 GB ram.

If I run 1 instance of my script, it hits 100% cpu, with processes at 180 and threads at like 4,000.
If I run multiple instances of the same script, it hits 250 processes and 7,000 threads…

Essentially the single script NOT using the full processing power…
Is there any way to adjust the code so I wont need to run multiple instances of it?

here is the code:

if name == ‘main’:
manager = multiprocessing.Manager()
return_dict = manager.dict()
processes =

if == 0:
    inst_count = multiprocessing.cpu_count()
    inst_count = test.NUM_INSTANCES

for i in range(inst_count):
    p= multiprocessing.Process(target=appname, args=(env.MAX_SECONDS, i, return_dict))

total = 0
for i in range(inst_count):
    proc_ret = return_dict[i]
    total += proc_ret

No. Python code only uses a single thread for the python code.
It can use more threads if you call into C code that does I/O or processing. But at a first approximation only 1 thread will be used.

You need to design your applacation so that it can run many instances of your code to use all the haredware CPU resource.

But you also need to take into account the I/O that your application does. That will effect how much CPU you can use. For example if you are waiting on disk or network I/O.

Thank you Barry!