A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
bugfix
jonaswinkler316ee72177b3
diff --git a/src/documents/management/commands/document_archiver.py b/src/documents/management/commands/document_archiver.pyindex 2e7e7b34d..7b9a123d9 100644--- a/src/documents/management/commands/document_archiver.py+++ b/src/documents/management/commands/document_archiver.py@@ -5,9 +5,9 @@ import loggingimport osimport shutilimport uuid-from time import sleepimport tqdm+from django import dbfrom django.conf import settingsfrom django.core.management.base import BaseCommandfrom django.db import transaction@@ -108,12 +108,21 @@ class Command(Renderable, BaseCommand):)))- logging.getLogger().handlers[0].level = logging.ERROR- with multiprocessing.Pool(processes=settings.TASK_WORKERS) as pool:- list(tqdm.tqdm(- pool.imap_unordered(- handle_document,- document_ids- ),- total=len(document_ids)- ))+ # Note to future self: this prevents django from reusing database+ # conncetions between processes, which is bad and does not work+ # with postgres.+ db.connections.close_all()++ try:++ logging.getLogger().handlers[0].level = logging.ERROR+ with multiprocessing.Pool(processes=settings.TASK_WORKERS) as pool:+ list(tqdm.tqdm(+ pool.imap_unordered(+ handle_document,+ document_ids+ ),+ total=len(document_ids)+ ))+ except KeyboardInterrupt:+ print("Aborting...")