AzurLaneAutoScript icon indicating copy to clipboard operation
AzurLaneAutoScript copied to clipboard

新版neMu_ipc接口导致报错功能触发失败

Open W1NDes opened this issue 2 years ago • 1 comments

在提问之前...

  • [X] 我已经搜索了现有的 issues
  • [X] 我在提问题之前至少花费了 5 分钟来思考和准备
  • [X] 我已经阅读了 Wiki 中的 常见问题(FAQ)
  • [X] 我正在使用最新版的 Alas

描述你的问题

新版neMu_ipc接口导致报错失败,一旦触发原先需要报错的情况就会触发 :
AttributeError: 'CaptureNemuIpc' object has no attribute 'old_stdout' 然后导致脚本原地等待,同时不会触发报错停止以及onepush预警

如何复现

采用最新版的mumu接口,触发异常

预期行为

望修复该bug,新接口很好😁

相关 Logs

────────────────────────────────── BATTLE_6 ───────────────────────────────────
INFO     18:55:37.551 │ BATTLE_6                                               
INFO     18:55:37.552 │ Auto search moving                                     
INFO     18:55:37.554 │ Fleet: 1, fleet_current_index: 1                       
INFO     18:55:37.644 │ [OCR_OIL 0.088s] 13826                                 
INFO     18:55:37.723 │ [OCR_OIL_LIMIT 0.077s] 14000                           
INFO     18:55:37.728 │ Reach oil limit                                        
INFO     18:55:37.780 │ [OCR_COIN 0.049s] 84548                                
INFO     18:55:37.845 │ [OCR_COIN_LIMIT 0.063s] 84000                          
WARNING  18:55:38.266 │ Func screenshot() call timeout, retrying               
ERROR    18:55:38.286 │ AttributeError: 'CaptureNemuIpc' object has no         
         attribute 'old_stdout'                                                
         ╭──────────────── Traceback (most recent call last) ─────────────────╮
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:331 in    │
         │ screenshot                                                         │
         │                                                                    │
         │   329 │   │                                                        │
         │   330 │   │   with CaptureNemuIpc():                               │
         │ ❱ 331 │   │   │   self.get_resolution()                            │
         │   332 │   │   │                                                    │
         │   333 │   │   │   width_ptr = ctypes.pointer(ctypes.c_int(self.wid │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │ self = <module.device.method.nemu_ipc.NemuIpcImpl object at    │ │
         │ │        0x00000133EC111D88>                                     │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:314 in    │
         │ get_resolution                                                     │
         │                                                                    │
         │   312 │   │   with CaptureNemuIpc():                               │
         │   313 │   │   │   ret = self.lib.nemu_capture_display(             │
         │ ❱ 314 │   │   │   │   self.connect_id, self.display_id, 0, width_p │
         │   315 │   │   if ret > 0:                                          │
         │   316 │   │   │   raise NemuIpcError('nemu_capture_display failed  │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │ height_ptr = <ctypes.wintypes.LP_c_long object at              │ │
         │ │              0x00000133CB7141C8>                               │ │
         │ │    nullptr = <ctypes.wintypes.LP_c_long object at              │ │
         │ │              0x00000133CB714DC8>                               │ │
         │ │        ret = 0                                                 │ │
         │ │       self = <module.device.method.nemu_ipc.NemuIpcImpl object │ │
         │ │              at 0x00000133EC111D88>                            │ │
         │ │  width_ptr = <ctypes.wintypes.LP_c_long object at              │ │
         │ │              0x00000133CB714C48>                               │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:118 in    │
         │ __exit__                                                           │
         │                                                                    │
         │   116 │   │                                                        │
         │   117 │   │   CaptureNemuIpc.instance = None                       │
         │ ❱ 118 │   │   super().__exit__(exc_type, exc_val, exc_tb)          │
         │   119 │   │                                                        │
         │   120 │   │   self.check_stdout()                                  │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │ __class__ = <class                                             │ │
         │ │             'module.device.method.nemu_ipc.CaptureNemuIpc'>    │ │
         │ │    exc_tb = None                                               │ │
         │ │  exc_type = None                                               │ │
         │ │   exc_val = None                                               │ │
         │ │      self = <module.device.method.nemu_ipc.CaptureNemuIpc      │ │
         │ │             object at 0x00000133FFBC24C8>                      │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:71 in     │
         │ __exit__                                                           │
         │                                                                    │
         │    69 │                                                            │
         │    70 │   def __exit__(self, exc_type, exc_val, exc_tb):           │
         │ ❱  71 │   │   self._redirect_stdout(to=self.old_stdout)            │
         │    72 │   │   self._redirect_stderr(to=self.old_stderr)            │
         │    73 │   │   os.close(self.old_stdout)                            │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │   exc_tb = None                                                │ │
         │ │ exc_type = None                                                │ │
         │ │  exc_val = None                                                │ │
         │ │     self = <module.device.method.nemu_ipc.CaptureNemuIpc       │ │
         │ │            object at 0x00000133FFBC24C8>                       │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         ╰────────────────────────────────────────────────────────────────────╯
         AttributeError: 'CaptureNemuIpc' object has no attribute 'old_stdout' 
                                                                               
         During handling of the above exception, another exception occurred:   
                                                                               
         ╭──────────────── Traceback (most recent call last) ─────────────────╮
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:165 in    │
         │ retry_wrapper                                                      │
         │                                                                    │
         │   163 │   │   │   │   │   retry_sleep(_)                           │
         │   164 │   │   │   │   │   init()                                   │
         │ ❱ 165 │   │   │   │   return self.ev_run_sync(func, self, *args, * │
         │   166 │   │   │   # Can't handle                                   │
         │   167 │   │   │   except RequestHumanTakeover:                     │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │      _ = 1                                                     │ │
         │ │   args = ()                                                    │ │
         │ │      e = AttributeError("'CaptureNemuIpc' object has no        │ │
         │ │          attribute 'old_stdout'")                              │ │
         │ │   func = <function NemuIpcImpl.screenshot at                   │ │
         │ │          0x00000133FFB004C8>                                   │ │
         │ │   init = <function retry.<locals>.retry_wrapper.<locals>.init  │ │
         │ │          at 0x00000133CB794D38>                                │ │
         │ │ kwargs = {}                                                    │ │
         │ │   self = <module.device.method.nemu_ipc.NemuIpcImpl object at  │ │
         │ │          0x00000133EC111D88>                                   │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:298 in    │
         │ ev_run_sync                                                        │
         │                                                                    │
         │   296 │   │   │   asyncio.TimeoutError: If function call timeout   │
         │   297 │   │   """                                                  │
         │ ❱ 298 │   │   result = self._ev.run_until_complete(self.ev_run_asy │
         │   299 │   │   return result                                        │
         │   300                                                              │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │   args = (                                                     │ │
         │ │          │   <module.device.method.nemu_ipc.NemuIpcImpl object │ │
         │ │          at 0x00000133EC111D88>,                               │ │
         │ │          )                                                     │ │
         │ │   func = <function NemuIpcImpl.screenshot at                   │ │
         │ │          0x00000133FFB004C8>                                   │ │
         │ │ kwargs = {}                                                    │ │
         │ │   self = <module.device.method.nemu_ipc.NemuIpcImpl object at  │ │
         │ │          0x00000133EC111D88>                                   │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\toolkit\lib\asyncio\base_events.py:583 in  │
         │ run_until_complete                                                 │
         │                                                                    │
         │    581 │   │   │   raise RuntimeError('Event loop stopped before F │
         │    582 │   │                                                       │
         │ ❱  583 │   │   return future.result()                              │
         │    584 │                                                           │
         │    585 │   def stop(self):                                         │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │   future = <Task finished coro=<NemuIpcImpl.ev_run_async()     │ │
         │ │            done, defined at                                    │ │
         │ │            D:\AzurLaneAutoScript\module\device\method\nemu_… │ │
         │ │            exception=AttributeError("'CaptureNemuIpc' object   │ │
         │ │            has no attribute 'old_stdout'")>                    │ │
         │ │ new_task = True                                                │ │
         │ │     self = <_WindowsSelectorEventLoop running=False            │ │
         │ │            closed=False debug=False>                           │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:285 in    │
         │ ev_run_async                                                       │
         │                                                                    │
         │   283 │   │   """                                                  │
         │   284 │   │   func_wrapped = partial(func, *args, **kwargs)        │
         │ ❱ 285 │   │   result = await asyncio.wait_for(self._ev.run_in_exec │
         │       timeout=0.2)                                                 │
         │   286 │   │   return result                                        │
         │   287                                                              │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │         args = (                                               │ │
         │ │                │   <module.device.method.nemu_ipc.NemuIpcImpl  │ │
         │ │                object at 0x00000133EC111D88>,                  │ │
         │ │                )                                               │ │
         │ │         func = <function NemuIpcImpl.screenshot at             │ │
         │ │                0x00000133FFB004C8>                             │ │
         │ │ func_wrapped = functools.partial(<function                     │ │
         │ │                NemuIpcImpl.screenshot at 0x00000133FFB004C8>,  │ │
         │ │                <module.device.method.nemu_ipc.NemuIpcImpl      │ │
         │ │                object at 0x00000133EC111D88>)                  │ │
         │ │       kwargs = {}                                              │ │
         │ │         self = <module.device.method.nemu_ipc.NemuIpcImpl      │ │
         │ │                object at 0x00000133EC111D88>                   │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\toolkit\lib\asyncio\tasks.py:442 in        │
         │ wait_for                                                           │
         │                                                                    │
         │   440 │   │                                                        │
         │   441 │   │   if fut.done():                                       │
         │ ❱ 442 │   │   │   return fut.result()                              │
         │   443 │   │   else:                                                │
         │   444 │   │   │   fut.remove_done_callback(cb)                     │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │             cb = functools.partial(<function _release_waiter   │ │
         │ │                  at 0x00000133EAEC9948>, <Future finished      │ │
         │ │                  result=None>)                                 │ │
         │ │            fut = <Future finished                              │ │
         │ │                  exception=AttributeError("'CaptureNemuIpc'    │ │
         │ │                  object has no attribute 'old_stdout'")>       │ │
         │ │           loop = <_WindowsSelectorEventLoop running=False      │ │
         │ │                  closed=False debug=False>                     │ │
         │ │        timeout = 0.2                                           │ │
         │ │ timeout_handle = <TimerHandle cancelled when=523300.778>       │ │
         │ │         waiter = <Future finished result=None>                 │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\toolkit\lib\concurrent\futures\thread.py:5 │
         │ 7 in run                                                           │
         │                                                                    │
         │    55 │   │                                                        │
         │    56 │   │   try:                                                 │
         │ ❱  57 │   │   │   result = self.fn(*self.args, **self.kwargs)      │
         │    58 │   │   except BaseException as exc:                         │
         │    59 │   │   │   self.future.set_exception(exc)                   │
         │                                                                    │
         │ ╭── locals ───╮                                                    │
         │ │ self = None │                                                    │
         │ ╰─────────────╯                                                    │
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:339 in    │
         │ screenshot                                                         │
         │                                                                    │
         │   337 │   │   │                                                    │
         │   338 │   │   │   ret = self.lib.nemu_capture_display(             │
         │ ❱ 339 │   │   │   │   self.connect_id, self.display_id, length, wi │
         │       pixels_pointer)                                              │
         │   340 │   │   if ret > 0:                                          │
         │   341 │   │   │   raise NemuIpcError('nemu_capture_display failed  │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │ self = <module.device.method.nemu_ipc.NemuIpcImpl object at    │ │
         │ │        0x00000133EC111D88>                                     │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:118 in    │
         │ __exit__                                                           │
         │                                                                    │
         │   116 │   │                                                        │
         │   117 │   │   CaptureNemuIpc.instance = None                       │
         │ ❱ 118 │   │   super().__exit__(exc_type, exc_val, exc_tb)          │
         │   119 │   │                                                        │
         │   120 │   │   self.check_stdout()                                  │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │ __class__ = <class                                             │ │
         │ │             'module.device.method.nemu_ipc.CaptureNemuIpc'>    │ │
         │ │    exc_tb = <traceback object at 0x00000133ACC8ED88>           │ │
         │ │  exc_type = <class 'AttributeError'>                           │ │
         │ │   exc_val = AttributeError("'CaptureNemuIpc' object has no     │ │
         │ │             attribute 'old_stdout'")                           │ │
         │ │      self = <module.device.method.nemu_ipc.CaptureNemuIpc      │ │
         │ │             object at 0x00000133CB7A2DC8>                      │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         │                                                                    │
         │ D:\AzurLaneAutoScript\module\device\method\nemu_ipc.py:71 in     │
         │ __exit__                                                           │
         │                                                                    │
         │    69 │                                                            │
         │    70 │   def __exit__(self, exc_type, exc_val, exc_tb):           │
         │ ❱  71 │   │   self._redirect_stdout(to=self.old_stdout)            │
         │    72 │   │   self._redirect_stderr(to=self.old_stderr)            │
         │    73 │   │   os.close(self.old_stdout)                            │
         │                                                                    │
         │ ╭──────────────────────────── locals ────────────────────────────╮ │
         │ │   exc_tb = <traceback object at 0x00000133ACC8ED88>            │ │
         │ │ exc_type = <class 'AttributeError'>                            │ │
         │ │  exc_val = AttributeError("'CaptureNemuIpc' object has no      │ │
         │ │            attribute 'old_stdout'")                            │ │
         │ │     self = <module.device.method.nemu_ipc.CaptureNemuIpc       │ │
         │ │            object at 0x00000133CB7A2DC8>                       │ │
         │ ╰────────────────────────────────────────────────────────────────╯ │
         ╰────────────────────────────────────────────────────────────────────╯
         AttributeError: 'CaptureNemuIpc' object has no attribute 'old_stdout'

截图

No response

还有别的吗?

No response

W1NDes avatar Apr 10 '24 11:04 W1NDes

2024-04-11_alas.txt 我这里似乎也有一样的问题

BleakMaple avatar Apr 11 '24 00:04 BleakMaple