首页 > 解决方案 > Python Pexpect 期望得到超时错误

问题描述

期望函数超时。我正在发布我的代码以及手动完成的步骤

import pexpect
from pexpect import popen_spawn
child = popen_spawn.PopenSpawn('tibemsadmin -server localhost:7222 -user admin -password admin', cwd='C:/tibco/ems/8.5 - Copy/bin')
out = child.sendline('delete queue zzzzzzz')
child.expect('Are you sure (yes,no)?')
print(out)

手动完成时:

C:\tibco\ems\8.5 - Copy\bin>tibemsadmin -server localhost:7222 -user admin -password admin

TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2019 by TIBCO Software Inc.
All rights reserved.

Version 8.5.1 V4 9/12/2019

Connected to: tcp://localhost:7222
Type 'help' for commands help, 'exit' to exit:
tcp://localhost:7222> delete queue zzzzzzz
Are you sure (yes,no)? yes
Queue 'zzzzzzz' has been deleted
tcp://localhost:7222>

错误:

  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pexpect\expect.py", line 144, in timeout
    raise exc
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x019AE790>
searcher: searcher_re:
    0: re.compile(b'Are you sure (yes,no)?')
<pexpect.popen_spawn.PopenSpawn object at 0x019AE790>
searcher: searcher_re:
    0: re.compile(b'Are you sure (yes,no)?')

标签: pythonpexpect

解决方案


推荐阅读