Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
5451ebf6
authored
2025-01-10 13:44:01 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
MOD:线程池方式
1 parent
48a1a358
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
src/celery_compare/tasks.py
src/celery_compare/tasks.py
View file @
5451ebf
...
...
@@ -51,6 +51,7 @@ from common.tools.comparison import cp
from
common.tools.des
import
decode_des
import
threading
import
concurrent.futures
compare_log
=
logging
.
getLogger
(
'compare'
)
log_base
=
'[Compare]'
...
...
@@ -3715,11 +3716,14 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
@app.task
def
fsm_compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
try
:
producer_thread_fsm
=
threading
.
Thread
(
target
=
fsm_compare_thread
,
args
=
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
producer_thread_fsm
.
start
()
except
Exception
as
e
:
compare_log
.
info
(
'[fsm thread error] [error={0}]'
.
format
(
traceback
.
format_exc
()))
# try:
# producer_thread_fsm = threading.Thread(target=fsm_compare_thread, args=(application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
# producer_thread_fsm.start()
# except Exception as e:
# compare_log.info('[fsm thread error] [error={0}]'.format(traceback.format_exc()))
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
20
)
as
executor
:
# 使用map函数提交多个任务
results
=
list
(
executor
.
map
(
fsm_compare_thread
,
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
def
fsm_compare_thread
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
...
...
@@ -3784,11 +3788,14 @@ def fsm_compare_thread(application_id, application_entity, uniq_seq, ocr_res_id,
@app.task
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
try
:
producer_thread
=
threading
.
Thread
(
target
=
compare_thread
,
args
=
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
producer_thread
.
start
()
except
Exception
as
e
:
compare_log
.
info
(
'[thread error] [error={0}]'
.
format
(
traceback
.
format_exc
()))
# try:
# producer_thread = threading.Thread(target=compare_thread, args=(application_id, application_entity, uniq_seq, ocr_res_id, is_ca, is_cms))
# producer_thread.start()
# except Exception as e:
# compare_log.info('[thread error] [error={0}]'.format(traceback.format_exc()))
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
20
)
as
executor
:
# 使用map函数提交多个任务
results
=
list
(
executor
.
map
(
compare_thread
,
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
,
is_cms
))
def
compare_thread
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
# POS: application_id, application_entity, uniq_seq, None
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment