-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy path__init__.py
More file actions
41 lines (36 loc) · 1.33 KB
/
__init__.py
File metadata and controls
41 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding=utf-8
"""
@project: maxkb
@Author:虎
@file: __init__.py
@date:2023/11/10 10:43
@desc:
"""
from django.core.cache import cache
from django.db.models import QuerySet
from django.utils.translation import gettext as _
from ..constants.cache_version import Cache_Version
from ..db.sql_execute import update_execute
from ..utils.lock import RedisLock
update_document_status_sql = """
UPDATE "public"."document"
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
WHERE status ~ '1|0|4' \
"""
def run():
from models_provider.models import Model, Status
rlock = RedisLock()
if rlock.try_lock('event_init', 30 * 30):
try:
# 修改Model状态为ERROR
QuerySet(Model).filter(
status=Status.DOWNLOAD
).update(
status=Status.ERROR, meta={'message': _('The download process was interrupted, please try again')}
)
# 更新文档状态
update_execute(update_document_status_sql, [])
version, get_key = Cache_Version.SYSTEM.value
cache.delete(get_key(key='rsa_key'), version=version)
finally:
rlock.un_lock('event_init')