diff --git a/danding_bot/plugins/group_horse_racing/test_commands.py b/danding_bot/plugins/group_horse_racing/test_commands.py index 56cba00..dea227a 100644 --- a/danding_bot/plugins/group_horse_racing/test_commands.py +++ b/danding_bot/plugins/group_horse_racing/test_commands.py @@ -205,24 +205,17 @@ async def handle_test_simulate_race(bot: Bot, event: Event): await test_simulate_race_cmd.send("收到:测试模拟赛马,开始执行完全模拟(无真实积分/数据库副作用)") scope = get_scope(event) - lock = room_store.get_lock(scope) - try: - await asyncio.wait_for(lock.acquire(), timeout=3) - except TimeoutError: - await test_simulate_race_cmd.finish("完全模拟失败:房间锁被占用(可能有卡住的赛马/测试任务),请稍后重试或先重启 Bot") - return - try: race_engine.stop_race(scope) room_store.delete_room(scope) - finally: - lock.release() - + except Exception: + pass original_room_store = commands_mod.room_store original_points_service = commands_mod.points_service original_message_service = commands_mod.message_service original_tick_interval = commands_mod.config.RACE_TICK_INTERVAL + fake_room_store = _InMemoryRoomStore() fake_points_service = _InMemoryPointsService() fake_message_service = _NoopMessageService() @@ -232,6 +225,7 @@ async def handle_test_simulate_race(bot: Bot, event: Event): room = None try: + await test_simulate_race_cmd.send("阶段:构建沙盒环境与参赛数据") commands_mod.room_store = fake_room_store commands_mod.points_service = fake_points_service commands_mod.message_service = fake_message_service @@ -252,6 +246,7 @@ async def handle_test_simulate_race(bot: Bot, event: Event): for horse in room.horses.values(): horse.state = HorseState.RACING + await test_simulate_race_cmd.send("阶段:执行赛程(后台任务)") start_task = asyncio.create_task(commands_mod.run_race_with_settlement(fake_bot, room, scope)) commands_mod.race_engine.register_task(scope, start_task) await asyncio.wait_for(start_task, timeout=15)