diff --git a/apps/common/event/listener_manage.py b/apps/common/event/listener_manage.py index 4982fa03b..9feea20e3 100644 --- a/apps/common/event/listener_manage.py +++ b/apps/common/event/listener_manage.py @@ -253,7 +253,7 @@ class ListenerManagement: """ if state_list is None: state_list = [State.PENDING, State.SUCCESS, State.FAILURE, State.REVOKE, State.REVOKED] - if not try_lock('embedding' + str(document_id)): + if not try_lock('embedding:' + str(document_id)): return try: def is_the_task_interrupted(): @@ -290,7 +290,7 @@ class ListenerManagement: ListenerManagement.post_update_document_status(document_id, TaskType.EMBEDDING) ListenerManagement.get_aggregation_document_status(document_id)() maxkb_logger.info(_('End--->Embedding document: {document_id}').format(document_id=document_id)) - un_lock('embedding' + str(document_id)) + un_lock('embedding:' + str(document_id)) @staticmethod def embedding_by_knowledge(knowledge_id, embedding_model: Embeddings): diff --git a/apps/common/utils/lock.py b/apps/common/utils/lock.py index 4276f1c65..010b69580 100644 --- a/apps/common/utils/lock.py +++ b/apps/common/utils/lock.py @@ -20,7 +20,9 @@ def try_lock(key: str, timeout=None): :param timeout 超时时间 :return: 是否获取到锁 """ - return memory_cache.add(key, 'lock', timeout=timedelta(hours=1).total_seconds() if timeout is not None else timeout) + if timeout is None: + timeout = 3600 # 默认超时时间为3600秒 + return memory_cache.add(key, 'lock', timeout=timeout) def un_lock(key: str):