|
|
@@ -67,29 +67,6 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
|
active_connections.discard(websocket)
|
|
|
|
|
|
|
|
|
-async def restart_smart_shooter_listener():
|
|
|
- """重启smart shooter监听器"""
|
|
|
- loop = asyncio.get_event_loop()
|
|
|
- if not hasattr(smart_shooter, "_listen_tasks"):
|
|
|
- smart_shooter._listen_tasks = set()
|
|
|
- while True:
|
|
|
- if getattr(smart_shooter, "listen_init", False):
|
|
|
- print("listen_init=====>", getattr(smart_shooter, "listen_init", False))
|
|
|
- break
|
|
|
- listen_task = loop.run_in_executor(None, smart_shooter.connect_listen)
|
|
|
- smart_shooter._listen_tasks.add(listen_task)
|
|
|
- # if smart_shooter.listen_init == False:
|
|
|
- # break
|
|
|
- try:
|
|
|
- await listen_task
|
|
|
- # 正常结束后等待重启
|
|
|
- await asyncio.sleep(1)
|
|
|
- except Exception as e:
|
|
|
- await asyncio.sleep(1)
|
|
|
- finally:
|
|
|
- smart_shooter._listen_tasks.discard(listen_task)
|
|
|
-
|
|
|
-
|
|
|
async def start_smart_shooter_listen():
|
|
|
"""启动 smart_shooter 监听服务"""
|
|
|
loop = asyncio.get_event_loop()
|
|
|
@@ -173,7 +150,7 @@ async def MsgCallback(msg):
|
|
|
if PhotoOrigin != "" and PhotoOrigin != "external":
|
|
|
goods_art_no, id = PhotoOrigin.split(",")
|
|
|
# 创建任务来处理数据库更新,避免阻塞回调
|
|
|
- asyncio.create_task(updateDataRecord(PhotoFilename, id))
|
|
|
+ await updateDataRecord(PhotoFilename, id)
|
|
|
data = conn_manager.jsonMessage(
|
|
|
code=0,
|
|
|
msg=f"照片获取成功",
|