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

Partial hang fix from #520 breaks proxy sockets #774

Closed
bitprophet opened this issue Jul 14, 2016 · 4 comments
Closed

Partial hang fix from #520 breaks proxy sockets #774

bitprophet opened this issue Jul 14, 2016 · 4 comments
Labels
Milestone

Comments

@bitprophet
Copy link
Member

An anonymous user noted via email that the partial fix committed earlier for #520 breaks on the "using a Channel as a proxy socket" use case (as seen eg via Fabric with env.gateway set - though I think this user was doing it independently of that).

Specifically, the issue happens because socket objects (under Py3) exhibit ._closed, but Channel objects exhibit .closed. Since the earlier fix branches into a test of sock._closed under Python 3, an AttributeError is raised:

  File "/opt/virtenv/3.5.2/lib/python3.5/site-packages/paramiko/client.py", line 394, in close
    self._transport.close()
  File "/opt/virtenv/3.5.2/lib/python3.5/site-packages/paramiko/transport.py", line 645, in close
    self.stop_thread()
  File "/opt/virtenv/3.5.2/lib/python3.5/site-packages/paramiko/transport.py", line 1550, in stop_thread
    and not self.sock._closed and not self.packetizer.closed
AttributeError: 'Channel' object has no attribute '_closed'

As this user suggests, I think a simple hasattr test added to the mix ought to suffice; this would also help with situations where socket.closed becomes a real API (ISTR confusion on this point during dev of the earlier fix anyways - but that was probably Python 2 vs 3.)

@bitprophet bitprophet added the Bug label Jul 14, 2016
@bitprophet bitprophet added this to the 1.16.3 et al milestone Jul 14, 2016
@bitprophet
Copy link
Member Author

Spliced gateway support into Fabric 2 & confirmed this myself under Python 3. Fix inbound.

bitprophet added a commit that referenced this issue Jul 26, 2016
@bitprophet
Copy link
Member Author

Turns out just updating Channel to expose both attributes was way more elegant than doing some hackneyed getattr stuff elsewhere.

@nvgoldin
Copy link

Hi, after installing 2.0.2, I'm still getting the same error when using ProxyCommand:

traceback (most recent call last):
  File "testing.py", line 16, in <module>
    ssh.close()
  File "/home/ngoldin/virtualenv/python3.5/lib/python3.5/site-packages/paramiko/client.py", line 394, in close
    self._transport.close()
  File "/home/ngoldin/virtualenv/python3.5/lib/python3.5/site-packages/paramiko/transport.py", line 645, in close
    self.stop_thread()
  File "/home/ngoldin/virtualenv/python3.5/lib/python3.5/site-packages/paramiko/transport.py", line 1552, in stop_thread
    and not self.sock._closed and not self.packetizer.closed
AttributeError: 'ProxyCommand' object has no attribute '_closed'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/ngoldin/virtualenv/python3.5/lib/python3.5/site-packages/paramiko/transport.py", line 77, in _join_lingering_threads
    thr.stop_thread()
  File "/home/ngoldin/virtualenv/python3.5/lib/python3.5/site-packages/paramiko/transport.py", line 1552, in stop_thread
    and not self.sock._closed and not self.packetizer.closed
AttributeError: 'ProxyCommand' object has no attribute '_closed'

@bitprophet
Copy link
Member Author

Well that'd be because ProxyCommand isn't Channel, so it never got the fix. Bah! Thanks for the report. Will make a new ticket & fix that real quick

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

No branches or pull requests

2 participants