From 9badd3b0732f217704c887ba5be868211e2bb0f1 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 30 Jan 2026 17:43:03 +0700 Subject: [PATCH] add timeout overwrite in es get, extend in zip backups --- backend/appsettings/src/backup.py | 3 ++- backend/common/src/es_connect.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/appsettings/src/backup.py b/backend/appsettings/src/backup.py index 702acd99..c4569196 100644 --- a/backend/appsettings/src/backup.py +++ b/backend/appsettings/src/backup.py @@ -21,7 +21,7 @@ class ElasticBackup: """dump index to nd-json files for later bulk import""" INDEX_SIZE_CONF = { - "comment": 200, + "comment": 100, "subtitle": 10000, } CACHE_DIR = EnvironmentSettings.CACHE_DIR @@ -64,6 +64,7 @@ class ElasticBackup: "callback": BackupCallback, "task": self.task, "total": self._get_total(index_name), + "timeout": 30, } if size_overwrite := self.INDEX_SIZE_CONF.get(index_name): diff --git a/backend/common/src/es_connect.py b/backend/common/src/es_connect.py index ecd46661..6638ffc8 100644 --- a/backend/common/src/es_connect.py +++ b/backend/common/src/es_connect.py @@ -148,6 +148,7 @@ class IndexPaginate: - callback: obj, Class implementing run method callback for every loop - task: task object to send notification - total: int, total items in index for progress message + - timeout: int, overwrite timeout in get request """ DEFAULT_SIZE = 500 @@ -191,7 +192,11 @@ class IndexPaginate: all_results = [] counter = 0 while True: - response, _ = ElasticWrap("_search").get(data=self.data) + get_kwargs = {"data": self.data} + if timeout_overwrite := self.kwargs.get("timeout"): + get_kwargs.update({"timeout": timeout_overwrite}) + + response, _ = ElasticWrap("_search").get(**get_kwargs) all_hits = response["hits"]["hits"] if not all_hits: break