8000 Shell prompt hangs once Result is printed when at least one host fails if InitNornir is done inside main() · Issue #884 · nornir-automation/nornir · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Shell prompt hangs once Result is printed when at least one host fails if InitNornir is done inside main() #884
Open
@deep-blue-pulsar

Description

@deep-blue-pulsar

Whenever an NXOS device using the ssh driver in the inventory is unreachable, tasks will complete normally for all reachable hosts and fail for the unreachable one but once the execution is complete, the shell prompt will be locked for input for about 45 seconds per successful NXOS host in the inventory. So if there are 10 successful hosts, and a single one fails, I'll be waiting at least 7 min to get my prompt back unless I send an interrupt signal.

I've stripped down my code to the bare minimum to try narrowing down the issue and arrived to this:

def main():

    nr = InitNornir("config.yaml")
    load_dotenv()
    nr.inventory.defaults.username = os.getenv("USERNAME")
    nr.inventory.defaults.password = os.getenv("PASSWORD")

    result = nr.run(task=napalm_get, getters=["config"])

    print_result(result)


if __name__ == "__main__":
    main()

If I take the code out of the main() function I can't reproduce it. If I also create the Nornir object inside a class in another module and instantiate an object of that class inside a main function the issue doesn't seem to happen.

Any idea why this happens? What am I doing wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0