Skip to content

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

Enhancement: add timeout for Tika client (#8520)

HiranChaudhuri452ea2ccf9a3
diff --git a/src/paperless_tika/parsers.py b/src/paperless_tika/parsers.py
index f51a03916..40aa8e581 100644
--- a/src/paperless_tika/parsers.py
+++ b/src/paperless_tika/parsers.py
@@ -33,7 +33,10 @@ class TikaDocumentParser(DocumentParser):
def extract_metadata(self, document_path, mime_type):
try:
- with TikaClient(tika_url=settings.TIKA_ENDPOINT) as client:
+ with TikaClient(
+ tika_url=settings.TIKA_ENDPOINT,
+ timeout=settings.CELERY_TASK_TIME_LIMIT,
+ ) as client:
parsed = client.metadata.from_file(document_path, mime_type)
return [
{
@@ -54,7 +57,10 @@ class TikaDocumentParser(DocumentParser):
self.log.info(f"Sending {document_path} to Tika server")
try:
- with TikaClient(tika_url=settings.TIKA_ENDPOINT) as client:
+ with TikaClient(
+ tika_url=settings.TIKA_ENDPOINT,
+ timeout=settings.CELERY_TASK_TIME_LIMIT,
+ ) as client:
try:
parsed = client.tika.as_text.from_file(document_path, mime_type)
except httpx.HTTPStatusError as err: