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 89d396dd
authored
Dec 19, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]进程优化
1 parent
cc524ed5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
main.py
main.py
View file @
89d396d
...
...
@@ -238,13 +238,17 @@ def start_process():
log
.
info
(
f
"process:{process}"
)
process
.
start
()
def
start_process_kafka
():
process_pool
=
multiprocessing
.
Pool
(
processes
=
2
,
initializer
=
consumer_process_init
)
processes_num
=
2
process_pool
=
multiprocessing
.
Pool
(
processes
=
processes_num
,
initializer
=
consumer_process_init
)
log
.
info
(
f
"main process_pool1:{process_pool}"
)
process_pool
.
apply_async
(
func
=
funasr_consumer
.
consume_kafka
,
# args=(),
callback
=
consumer_process_callback
,
error_callback
=
consumer_process_error_callback
)
for
i
in
range
(
processes_num
):
process_pool
.
apply_async
(
func
=
funasr_consumer
.
consume_kafka
,
# args=(),
callback
=
consumer_process_callback
,
error_callback
=
consumer_process_error_callback
)
def
consumer_process_init
():
process_name
=
str
(
multiprocessing
.
current_process
()
.
name
)
...
...
@@ -258,6 +262,7 @@ def consumer_process_init():
# except Exception as e:
# log.error(f"consumer_process_init_error process_name:{process_name}", e)
def
consumer_process_callback
(
res
):
log
.
info
(
f
"consumer_process_callback:{multiprocessing.current_process().name}, res:{res}"
)
# count = funasr_db.select_process_all_end()
...
...
@@ -269,6 +274,7 @@ def consumer_process_callback(res):
# funasr_service.handle_process(str(message))
gc
.
collect
()
def
consumer_process_error_callback
(
err
):
log
.
error
(
f
"consumer_process_error_callback:{err}"
)
gc
.
collect
()
...
...
@@ -276,7 +282,7 @@ def consumer_process_error_callback(err):
if
__name__
==
"__main__"
:
log
.
info
(
"funasr main starting..."
)
start_kafka
()
start_
process_
kafka
()
funasr_producer
.
send_wait_task
()
ap_scheduler_util
.
scheduler_start
()
save_path
=
"audios/"
...
...
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