SSHException("Channel closed.") thrown
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
paramiko |
Fix Released
|
High
|
Robey Pointer |
Bug Description
My use paramiko via Fabric is failling intermittently. Every so often, the following exception occurs:
Traceback (most recent call last):
File "/home/
commands[
File "/home/
run('sed -i "s/#alias /alias /g" .bashrc')
File "/home/
return func(*args, **kwargs)
File "/home/
channel.
File "/home/
self.
File "/home/
raise e
paramiko.
This is occurring due to the change in behavior of the _wait_for_event method between versions 1.7.4 and 1.7.5. Before, _wait_for_event was returning whenever self.event.isSet() was true, regardless of the self.closed value. In version 1.7.5, the following sequence of events is now possible:
1. A request is made, clearing self.event.
2. The request completes, setting self.event.
3. The channel is closed, setting self.closed.
4. _wait_for_event is finally called, tests that self.closed is true, and raises SSHException(
99 times out of 100, steps 3 and 4 happen in the opposite order, but if the thread swapping happens just right, the above occurs.
Changed in paramiko: | |
status: | Fix Committed → Fix Released |
Just in case the attached svn diff is hard to use, I have attached the complete channel.py source.