Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell prompt hangs once Result is printed when at least one host fails if InitNornir is done inside main() #884

Open
deep-blue-pulsar opened this issue Dec 8, 2023 · 0 comments

Comments

@deep-blue-pulsar
Copy link

deep-blue-pulsar commented Dec 8, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant