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

SshMachine() hangs few seconds after an exception #306

Closed
ghost opened this issue Dec 31, 2016 · 2 comments
Closed

SshMachine() hangs few seconds after an exception #306

ghost opened this issue Dec 31, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 31, 2016

This exception is raised by SshMachine() when I try to connect to a host that does not exist:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/session.py", line 108, in communicate
    line = pipe.readline()
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/session.py", line 56, in readline
    raise EOFError()
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.bin/gl/nssh", line 119, in <module>
    main()
  File "/home/user/.bin/gl/nssh", line 113, in main
    RemoteShell(host=sys.argv[1])
  File "/home/user/.bin/gl/nssh", line 44, in __init__
    self.connect(host)
  File "/home/user/.bin/gl/nssh", line 90, in connect
    self.ssh = SshMachine(self.host)
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/ssh_machine.py", line 106, in __init__
    new_session = new_session)
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/remote.py", line 162, in __init__
    self._session = self.session(new_session = new_session)
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/ssh_machine.py", line 172, in session
    self.encoding, isatty, self.connect_timeout)
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/session.py", line 169, in __init__
    self.run("")
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/session.py", line 252, in run
    return run_proc(self.popen(cmd), retcode)
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/commands/processes.py", line 196, in run_proc
    stdout, stderr = proc.communicate()
  File "/home/user/.local/lib/python3.5/site-packages/plumbum/machines/session.py", line 121, in communicate
    raise SSHCommsChannel2Error(msgerr) if name=="2" else SSHCommsError(msg)
plumbum.machines.session.SSHCommsError: No communication channel detected. Does the remote exist?

After the exception above, plumbum hangs few seconds. It looks like it is waiting for the thread to complete (even when I catch the exception above + I quit with sys.exit(), plumbum is still hanging... It looks like a thread that wasn't canceled).

Thank you.

Asher256

@ghost ghost changed the title Cannot catch the exception plumbum.machines.session.SSHCommsError: SshMachine() waits few seconds after an exception Dec 31, 2016
@ghost ghost changed the title SshMachine() waits few seconds after an exception SshMachine() hangs few seconds after an exception Dec 31, 2016
henryiii added a commit that referenced this issue Dec 31, 2016
@henryiii
Copy link
Collaborator

Fixed in master, see if that works for you.

@henryiii henryiii reopened this Dec 31, 2016
@ghost
Copy link
Author

ghost commented Dec 31, 2016

Your change solved the issue Henryiii!

--
Asher256

PS: I wanted to thank you for the Python module plumbum. It is an excellent replacement for openssh_wrapper + python_sh modules + it is pythonnic and fully compatible with Python 3. Keep up with the good work!

@ghost ghost closed this as completed Dec 31, 2016
This issue was closed.
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