79342133

Date: 2025-01-09 09:55:11
Score: 1
Natty:
Report link

I guess you are creating the pool twice (read_pool = multiprocessing.Pool(4)), which may be causing issues with the join() method.

Remember when you call map_async(), it doesn not block until you call get(), which is why the code continues without waiting for the tasks to finish.

In order to fix this one, you need to remove the redundant pool creation and just use read_jobs.get(). This will make sure the proper blocking. Here's an updated example:

with multiprocessing.Pool(processes=4) as read_pool: read_jobs = read_pool.map_async(func=read_image_task, iterable=[(filename, image_directory, queue) for filename in images_to_ocr]) read_pool.close() read_pool.join() read_jobs.get()

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Ahmed Noor