Add option to limit tesseract threads
This commit is contained in:
parent
b7f0654526
commit
824e305bb0
@ -193,12 +193,21 @@ def _pdftesseract(config, path):
|
|||||||
"Suspecting full file system, failing")
|
"Suspecting full file system, failing")
|
||||||
return False, ""
|
return False, ""
|
||||||
|
|
||||||
|
nenv = os.environ.copy()
|
||||||
|
cnthreads = config.getConfParam("tesseractnthreads")
|
||||||
|
if cnthreads:
|
||||||
|
try:
|
||||||
|
nthreads = int(cnthreads)
|
||||||
|
nenv['OMP_THREAD_LIMIT'] = cnthreads
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
for f in sorted(ppmfiles):
|
for f in sorted(ppmfiles):
|
||||||
out = b''
|
out = b''
|
||||||
try:
|
try:
|
||||||
out = subprocess.check_output(
|
out = subprocess.check_output(
|
||||||
[tesseractcmd, f, f, "-l", tesseractlang],
|
[tesseractcmd, f, f, "-l", tesseractlang],
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT, env=nenv)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_deb("%s failed: %s" % (tesseractcmd,e))
|
_deb("%s failed: %s" % (tesseractcmd,e))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user