Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Ensure `OCR_THREADS` is integer, add documentation

Pit Kleyersburg20b2408dbbbb
diff --git a/docs/setup.rst b/docs/setup.rst
index 1ca9a6ed3..24a9b9fa2 100644
--- a/docs/setup.rst
+++ b/docs/setup.rst
@@ -58,6 +58,11 @@ Standard (Bare Metal)
passphrase from the environment, so if you don't set it to a static value
here, you must set ``PAPERLESS_PASSPHRASE=some-secret-string`` on the
command line whenever invoking the consumer or webserver.
+ * ``OCR_THREADS``: this is the number of threads the OCR process will spawn
+ to process document pages in parallel. The default value gets sourced from
+ the environment-variable ``PAPERLESS_OCR_THREADS`` and expects it to be an
+ integer. If the variable is not set, Python determines the core-count of
+ your CPU and uses that value.
4. Initialise the database with ``./manage.py migrate``.
5. Create a user for your Paperless instance with
``./manage.py createsuperuser``. Follow the prompts to create your user.
diff --git a/src/documents/consumer.py b/src/documents/consumer.py
index 3f3b9e9a3..2fa0ea016 100644
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@ -52,7 +52,7 @@ class Consumer(Renderable):
SCRATCH = settings.SCRATCH_DIR
CONVERT = settings.CONVERT_BINARY
CONSUME = settings.CONSUMPTION_DIR
- THREADS = settings.OCR_THREADS
+ THREADS = int(settings.OCR_THREADS) if settings.OCR_THREADS else None
OCR = pyocr.get_available_tools()[0]
DEFAULT_OCR_LANGUAGE = settings.OCR_LANGUAGE