<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>I just committed changeset 1e498581a094, which should fix the issue. Please give it a try and let me know. Otherwise, it will be contained in release 23.12 as is.</p>
<p>Regards,
Detlev
</p>
<p><style type="text/css">p, li { white-space: pre-wrap; }hr { height: 1px; border-width: 0; }li.unchecked::marker { content: "\2610"; }li.checked::marker { content: "\2612"; }</style></p>
<div class="moz-cite-prefix">Am 15.11.23 um 16:33 schrieb Jamie
Riotto:<br>
</div>
<blockquote type="cite"
cite="mid:CAM8_zThQPpb_AiiQUyD+tcPRLPR+zp3wEUZoc4efg90_eBHFNQ@mail.gmail.com">
<div>import multiprocessing<br>
from time import time<br>
import random<br>
<br>
<br>
def parallelSim(job_queue, output_queue):<br>
for data in iter(job_queue.get, 'STOP'):<br>
choices = random.choices(data, k=10)<br>
total = 0<br>
for i, c in enumerate(choices):<br>
sign = 1 if i%2==0 else -1<br>
total += c * c * sign<br>
<br>
output_queue.put(total)<br>
<br>
if __name__ == '__main__':<br>
start_time = time()<br>
<br>
job_queue = multiprocessing.Queue()<br>
output_queue = multiprocessing.Queue()<br>
<br>
# create some data<br>
data = list(range(1, 1000))<br>
<br>
# DEBUG<br>
#numCPUs = multiprocessing.cpu_count()<br>
numCPUs = 4<br>
iterations = 10<br>
numjobs = numCPUs * iterations<br>
<br>
# load up the job queue<br>
for sim in range(numjobs):<br>
job_queue.put(data)<br>
<br>
# add Stops to the job queue<br>
for x in range(numCPUs):<br>
job_queue.put('STOP')<br>
<br>
serialDebug = False<br>
if serialDebug is True:<br>
# Debug the Parallel Process<br>
parallelSim(job_queue, output_queue)<br>
<br>
else:<br>
# parallelize processing using a pool of processes<br>
for i in range(numCPUs):<br>
multiprocessing.Process(target=parallelSim,
args=(job_queue, output_queue)).start()<br>
<br>
results = []<br>
for r in range(numjobs):<br>
results.append(output_queue.get())<br>
<br>
avg_result = sum(results) / numjobs<br>
print("")<br>
print(f'Average Results = {avg_result}')<br>
<br>
end_time = time()<br>
elapsed = end_time - start_time<br>
print(f"Finished in: {elapsed:.3f} seconds")<br>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Detlev Offenbach
<a class="moz-txt-link-abbreviated" href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a></pre>
</body>
</html>