【发布时间】:2021-11-19 08:49:50
【问题描述】:
我们正在尝试在特定路径打开资源管理器窗口,然后等待准备就绪。客户端是通过rpyc 操作的,因此堆栈跟踪很奇怪。这有时会发生,但仅在同一个测试中。这个函数 (fileman_item_properties) 用于打开文件属性窗口,它在许多不同的地方都可以正常工作。
command = f'explorer.exe'
Timings.slow()
try:
Application().start(f'{command} /select,{item}')
app = Application(backend='uia').connect(path=command)
app.wait_cpu_usage_lower(threshold=0.5, timeout=60, usage_interval=1.0)
4 Traceback (most recent call last):
265 File "/home/serj/work/mpksoft/te/tests/test_vss_simple.py", line 540, in test_restore_root_share_dirs
266 fileman_restore_item(client, self._share_path, version)
267 File "/home/serj/work/mpksoft/te/lib/host/coreui.py", line 377, in fileman_restore_item
268 host_plugin_load(conn, 'coreui').fileman_restore_item(path, version)
269 File "/home/serj/work/.virtualenvs/te36/lib/python3.6/site-packages/rpyc/core/netref.py", line 240, in __call__
270 return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
271 File "/home/serj/work/.virtualenvs/te36/lib/python3.6/site-packages/rpyc/core/netref.py", line 63, in syncreq
272 return conn.sync_request(handler, proxy, *args)
273 File "/home/serj/work/.virtualenvs/te36/lib/python3.6/site-packages/rpyc/core/protocol.py", line 473, in sync_request
274 return self.async_request(handler, *args, timeout=timeout).value
275 File "/home/serj/work/.virtualenvs/te36/lib/python3.6/site-packages/rpyc/core/async_.py", line 102, in value
276 raise self._obj
277 rpyc.core.vinegar/pywintypes._get_exception_class.<locals>.Derived: (87, 'OpenProcess', 'The parameter is incorrect.')
278
279 ========= Remote Traceback (1) =========
280 Traceback (most recent call last):
281 File "C:\Program Files\Python38\lib\site-packages\rpyc\core\protocol.py", line 320, in _dispatch_request
282 res = self._HANDLERS[handler](self, *args)
283 File "C:\Program Files\Python38\lib\site-packages\rpyc\core\protocol.py", line 593, in _handle_call
284 return obj(*args, **dict(kwargs))
285 File ".\windows\coreui.py", line 1285, in fileman_restore_item
286 fileman_item_properties(path)
287 File ".\windows\coreui.py", line 422, in fileman_item_properties
288 app.wait_cpu_usage_lower(threshold=0.5, timeout=60, usage_interval=1.0)
289 File "C:\Program Files\Python38\lib\site-packages\pywinauto\application.py", line 1135, in wait_cpu_usage_lower
290 while self.cpu_usage(usage_interval) > threshold:
291 File "C:\Program Files\Python38\lib\site-packages\pywinauto\application.py", line 1110, in cpu_usage
292 h_process = win32api.OpenProcess(win32con.MAXIMUM_ALLOWED, 0, self.process)
293 pywintypes.error: (87, 'OpenProcess', 'The parameter is incorrect.')
UPD
很遗憾,下面的代码没有解决问题。未就绪的进程不知何故通过connect 超时。
Application().start(f'{command} /select,{item}')
app = Application(backend='uia').connect(path=command, title_re=f'.*{base_name}.*', timeout=60)
app.wait_cpu_usage_lower(threshold=0.5, timeout=60, usage_interval=1.0)
顺便说一句,在出错时资源管理器窗口尚未显示。
【问题讨论】:
标签: pywinauto windows-server-2019