From 77ea47f32b00d21a13c4fec93c6bc9f54a143dda Mon Sep 17 00:00:00 2001 From: MoonGem <34537029+MoonGem@users.noreply.github.com> Date: Sun, 25 Mar 2018 09:30:27 -0500 Subject: [PATCH] Better processing time, cut down on processing time. --- user_data/random/random.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/user_data/random/random.py b/user_data/random/random.py index 610af04b0..5df05414f 100644 --- a/user_data/random/random.py +++ b/user_data/random/random.py @@ -7,9 +7,8 @@ import re PROC_COUNT = multiprocessing.cpu_count() - 1 cwd = os.getcwd() print(cwd) - - -limit = multiprocessing.cpu_count() - 1 +global procs +limit = 24 WORK_DIR = os.path.join( os.path.sep, os.path.abspath(os.path.dirname(__file__)), @@ -24,14 +23,14 @@ command = [ ] global current current = 0 - +procs = 0 DEVNULL = open(os.devnull, 'wb') while True: - def Run(command): - global current - processes = [subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) for i in range(PROC_COUNT)] - for proc in processes: + while procs < 32: + try: + procs + 1 + proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) wait = proc.communicate() string = str(wait) params = re.search(r'~~~~(.*)~~~~', string).group(1) @@ -62,4 +61,6 @@ while True: if rsi: print('~~~RSI~~~') print(rsi.group(1)) - data = Run(command) + procs - 1 + except Exception as e: + print(e)