Improve CPU usage

This commit is contained in:
Andras Schmelczer 2022-07-01 19:57:24 +02:00
parent b56273e267
commit c1d32741c1

View file

@ -16,10 +16,10 @@ def mapper_function(
try: try:
while not should_stop.is_set(): while not should_stop.is_set():
try: try:
input_chunk = input_queue.get_nowait() input_chunk = input_queue.get(1)
output_chunk = [(i, map_function(v)) for i, v in input_chunk] output_chunk = [(i, map_function(v)) for i, v in input_chunk]
output_queue.put(output_chunk) output_queue.put(output_chunk)
except queue.Empty: except queue.Empty:
pass pass
except KeyboardInterrupt: except (KeyboardInterrupt, BrokenPipeError):
return return