You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mitogen/tests/soak/cpu_load.py

22 lines
457 B
Python

#!/usr/bin/env python
"""
Put the machine's CPUs under pressure to increase the likelihood of scheduling
weirdness. Useful for exposing otherwise difficult to hit races in the library.
"""
import multiprocessing
def burn():
while 1: pass
mul = 2
count = int(mul * multiprocessing.cpu_count())
print count
procs = [multiprocessing.Process(target=burn)
for _ in range(count)]
for i, proc in enumerate(procs):
print([i])
proc.start()