Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
funasr_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9bacdebc
authored
Mar 19, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
服务重启任务优化
1 parent
8c9dc8c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletions
kafka_service/funasr_producer.py
main.py
mysql_service/funasr_db.py
kafka_service/funasr_producer.py
View file @
9bacdeb
...
...
@@ -4,6 +4,7 @@ import uuid
from
log.logger
import
log
from
kafka
import
KafkaProducer
from
config.config
import
ConfigInfo
from
mysql_service
import
funasr_db
# 创建Kafka生产者
producer
=
KafkaProducer
(
bootstrap_servers
=
ConfigInfo
.
kafka_consumer_bootstrap_servers
)
# Kafka集群的地址
...
...
@@ -19,3 +20,16 @@ def send_message_analysis(message):
producer
.
send
(
ConfigInfo
.
kafka_consumer_analysis_topic
,
message
)
# 等待所有消息发送完成
producer
.
flush
()
def
send_wait_task
():
res
=
funasr_db
.
select_ali_asr_model_wait
()
json_res
=
json
.
loads
(
res
)
print
(
f
"服务启动推送等待任务:{json_res}"
)
for
item
in
json_res
:
task_id
=
item
[
'task_id'
]
data
=
{
"task_id"
:
task_id
}
message
=
json
.
dumps
(
data
)
.
encode
(
'utf-8'
)
producer
.
send
(
ConfigInfo
.
kafka_consumer_analysis_topic
,
message
)
print
(
f
"send success{task_id}"
)
# 等待所有消息发送完成
producer
.
flush
()
\ No newline at end of file
main.py
View file @
9bacdeb
...
...
@@ -200,6 +200,7 @@ def start_kafka():
if
__name__
==
"__main__"
:
start_kafka
()
funasr_producer
.
send_wait_task
()
save_path
=
"./audio/"
if
os
.
path
.
exists
(
save_path
):
shutil
.
rmtree
(
save_path
)
...
...
mysql_service/funasr_db.py
View file @
9bacdeb
...
...
@@ -33,5 +33,6 @@ def select_ali_asr_model_res(task_id: str):
def
select_ali_asr_model_wait
():
select_sql
=
(
f
"select id,task_id,file_url,task_status,output_data from ali_asr_model_res aamr where aamr.del_flag = 0 and aamr.output_data is null;"
)
f
"select id,task_id,file_url,task_status,output_data from ali_asr_model_res aamr where aamr.del_flag = 0 and "
f
"aamr.output_data is null and aamr.task_status = 0;"
)
return
db
.
execute_select
(
select_sql
)
Write
Preview
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