From 3e48f954396d3e973ef2bbc3871ddbfba4327a0a Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 4 Jul 2018 15:22:18 +0000 Subject: [PATCH] tests: import cpu_load.py. --- tests/soak/cpu_load.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/soak/cpu_load.py diff --git a/tests/soak/cpu_load.py b/tests/soak/cpu_load.py new file mode 100644 index 00000000..ed473b15 --- /dev/null +++ b/tests/soak/cpu_load.py @@ -0,0 +1,21 @@ +#!/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()