|
@@ -216,10 +216,8 @@ def db_process():
|
|
|
db_pro_init()
|
|
|
initialize_connection_pool()
|
|
|
|
|
|
- # 单线程执行器
|
|
|
- sync_executor = ThreadPoolExecutor(max_workers=1)
|
|
|
# 多线程执行器
|
|
|
- async_executor = ThreadPoolExecutor(max_workers=8) # 限制线程并发数
|
|
|
+ async_executor = ThreadPoolExecutor(max_workers=8, thread_name_prefix="AsyncDBWorker")
|
|
|
|
|
|
try:
|
|
|
while True:
|
|
@@ -231,7 +229,6 @@ def db_process():
|
|
|
if isinstance(db_request, DBRequest_Sync):
|
|
|
# 同步操作
|
|
|
handle_db_request(db_request)
|
|
|
- # sync_executor.submit(handle_db_request, db_request)
|
|
|
else:
|
|
|
# 异步操作
|
|
|
async_executor.submit(handle_db_request, db_request)
|
|
@@ -243,7 +240,6 @@ def db_process():
|
|
|
|
|
|
finally:
|
|
|
# 收到退出信号后,关闭执行器
|
|
|
- sync_executor.shutdown(wait=True)
|
|
|
async_executor.shutdown(wait=True)
|
|
|
db_worker_running = False
|
|
|
LOGERR("DB process exit gracefully")
|
|
@@ -251,7 +247,7 @@ def db_process():
|
|
|
# 创建数据库线程
|
|
|
def create_db_process():
|
|
|
global db_thread
|
|
|
- db_thread = threading.Thread(target=db_process, daemon=True)
|
|
|
+ db_thread = threading.Thread(target=db_process, daemon=True, name="DBWorkerThread")
|
|
|
return db_thread
|
|
|
|
|
|
# 停止数据库线程
|