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 c345c544
authored
Mar 25, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]进程池优化
1 parent
5eb41f08
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
kafka_service/funasr_consumer.py
log/logger.py
kafka_service/funasr_consumer.py
View file @
c345c54
...
@@ -73,18 +73,18 @@ def consume_kafka():
...
@@ -73,18 +73,18 @@ def consume_kafka():
log
.
info
(
f
"启动consume_kafka Thread name:{threading.current_thread().name}"
)
log
.
info
(
f
"启动consume_kafka Thread name:{threading.current_thread().name}"
)
# 消费消息并进行逻辑处理
# 消费消息并进行逻辑处理
try
:
try
:
process_pool
=
multiprocessing
.
Pool
(
processes
=
1
,
initializer
=
consumer_process_init
)
#
process_pool = multiprocessing.Pool(processes=1, initializer=consumer_process_init)
for
message
in
consumer_new
:
for
message
in
consumer_new
:
if
message
is
None
:
if
message
is
None
:
continue
continue
log
.
info
(
f
"Received message: {message}"
)
log
.
info
(
f
"Received message: {message}"
)
# 处理逻辑
# 处理逻辑
#
funasr_service.handle_process(str(message.value.decode('utf-8')))
funasr_service
.
handle_process
(
str
(
message
.
value
.
decode
(
'utf-8'
)))
arg
=
str
(
message
.
value
.
decode
(
'utf-8'
))
#
arg = str(message.value.decode('utf-8'))
log
.
info
(
f
"arg:{arg},process_pool1:{process_pool}"
)
#
log.info(f"arg:{arg},process_pool1:{process_pool}")
process_pool
.
apply_async
(
func
=
funasr_service
.
handle_process
,
args
=
(
arg
,),
#
process_pool.apply_async(func=funasr_service.handle_process, args=(arg,),
callback
=
consumer_process_callback
,
#
callback=consumer_process_callback,
error_callback
=
consumer_process_error_callback
)
#
error_callback=consumer_process_error_callback)
# process = multiprocessing.Process(target=funasr_service.handle_process, args=((str(message.value.decode('utf-8'))),),)
# process = multiprocessing.Process(target=funasr_service.handle_process, args=((str(message.value.decode('utf-8'))),),)
# process.start()
# process.start()
print
(
"task handle"
)
print
(
"task handle"
)
...
...
log/logger.py
View file @
c345c54
...
@@ -32,4 +32,4 @@ def setup_logging(log_file):
...
@@ -32,4 +32,4 @@ def setup_logging(log_file):
return
logger
return
logger
log
=
setup_logging
(
'
%
s/funasr.log'
%
"/app/soft/python_project/audio_dev/logs"
)
\ No newline at end of file
\ No newline at end of file
log
=
setup_logging
(
'
%
s/funasr_temp.log'
%
"/app/soft/python_project/audio_dev/logs"
)
\ No newline at end of file
\ No newline at end of file
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