switch from stdlib to loky.ProcessPoolExecutor, ensure shutdown

pull/142/head
Robert Sachunsky 4 months ago
parent f93c6c288d
commit 0ae28f7d3e

@ -5,3 +5,4 @@ scikit-learn >= 0.23.2
tensorflow < 2.13
imutils >= 0.5.3
numba <= 0.58.1
loky

@ -10,11 +10,12 @@ import math
import os
import sys
import time
import atexit
import warnings
from functools import partial
from pathlib import Path
from multiprocessing import cpu_count
from concurrent.futures import ProcessPoolExecutor
from loky import ProcessPoolExecutor
import gc
from ocrd_utils import getLogger
import cv2
@ -257,7 +258,8 @@ class Eynollah:
pcgts=pcgts)
self.logger = logger if logger else getLogger('eynollah')
# for parallelization of CPU-intensive tasks:
self.executor = ProcessPoolExecutor(max_workers=cpu_count())
self.executor = ProcessPoolExecutor(max_workers=cpu_count(), timeout=1200)
atexit.register(self.executor.shutdown)
self.dir_models = dir_models
self.model_dir_of_enhancement = dir_models + "/eynollah-enhancement_20210425"
self.model_dir_of_binarization = dir_models + "/eynollah-binarization_20210425"

Loading…
Cancel
Save