|
6 | 6 | @date:2023/11/10 10:43 |
7 | 7 | @desc: |
8 | 8 | """ |
9 | | -from models_provider.models import Model, Status |
10 | | -from .listener_manage import * |
11 | 9 | from django.utils.translation import gettext as _ |
12 | 10 |
|
13 | | -from ..db.sql_execute import update_execute |
14 | 11 | from common.lock.impl.file_lock import FileLock |
| 12 | +from .listener_manage import * |
| 13 | +from ..db.sql_execute import update_execute |
15 | 14 |
|
16 | 15 | lock = FileLock() |
17 | 16 | update_document_status_sql = """ |
18 | | -UPDATE "public"."document" |
19 | | -SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3') |
20 | | -WHERE status ~ '1|0|4' |
21 | | -""" |
| 17 | + UPDATE "public"."document" |
| 18 | + SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3') |
| 19 | + WHERE status ~ '1|0|4' \ |
| 20 | + """ |
22 | 21 |
|
23 | 22 |
|
24 | 23 | def run(): |
| 24 | + from models_provider.models import Model, Status |
| 25 | + |
25 | 26 | if lock.try_lock('event_init', 30 * 30): |
26 | 27 | try: |
27 | | - QuerySet(Model).filter(status=Status.DOWNLOAD).update(status=Status.ERROR, meta={'message': _( 'The download process was interrupted, please try again')}) |
| 28 | + # 修改Model状态为ERROR |
| 29 | + QuerySet(Model).filter( |
| 30 | + status=Status.DOWNLOAD |
| 31 | + ).update( |
| 32 | + status=Status.ERROR, meta={'message': _('The download process was interrupted, please try again')} |
| 33 | + ) |
| 34 | + # 更新文档状态 |
28 | 35 | update_execute(update_document_status_sql, []) |
29 | 36 | finally: |
30 | 37 | lock.un_lock('event_init') |
0 commit comments