[Python] Slow Execution of Pexpect Script - seems to be hitting 30s timeout each step

Discussão em 'Python' iniciado por Stack, Fevereiro 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am running the following script:

    pxssh.PROMPT = "user@firewall>"
    conn = pxssh.pxssh(options={
    "StrictHostKeyChecking": "no",
    "UserKnownHostsFile": "/dev/null"})
    conn.login(ip, user, pw, auto_prompt_reset=False, login_timeout=10)
    conn.prompt(timeout=1)
    conn.sendline("set cli pager off\r")
    conn.prompt(timeout=1)
    print(int(time.time()))
    conn.sendline("debug dataplane pow performance all\r")
    conn.prompt(timeout=1)
    output = conn.before
    conn.logout()


    The script completes and returns the correct data, but it was taking 30s plus for each step until I added the timeout for the prompt. Now the login takes 33s, but the prompts take a second or so.

    The login and each step are successful even with the delays.

    I have used pexpect in the past and don't remember having this issue.

    I was expecting that each command sent and each prompt would also send a "\r" or similar and cause the command to be entered on the cli and the response should be immediately returned.

    An interactive session from the same host has each step completes immediately with no delay.

    What have I missed? Or is this just expected behavior?

    Continue reading...

Compartilhe esta Página