[paramiko] bad file descriptor - patch included

Robey Pointer robey at lag.net
Mon Nov 27 11:19:56 PST 2006


On 23 Nov 2006, at 15:42, David Mason wrote:

> Hi again,
>
> Yesterday I asked about a "bad file descriptor" error that was  
> coming up as I was closing the SSH connection.  After some digging  
> I determined that it was happening due to the thread not picking up  
> that it is inactive until some time after the sockets are closed.   
> I've fixed this by making the close method in Transport wait for  
> the thread to terminate *before* it closes the open connection.   
> I've attached a patch that fixes this behaviour (text of patch is  
> also listed below).

Joining the thread before the packetizer is closed may cause the  
packetizer to never realize that it should stop, though.  (The unit  
tests break for this reason -- good demonstration of why they're  
actually useful!) :)

I think a better fix would be to notice when a socket.error happens  
because of EOF, and translate the exception.  Patch below -- does  
this fix it for you too?

robey


=== modified file 'paramiko/packet.py'
--- paramiko/packet.py  2006-11-12 06:30:54 +0000
+++ paramiko/packet.py  2006-11-27 19:13:31 +0000
@@ -218,6 +218,8 @@
                  # we need to work around it.
                  if (type(e.args) is tuple) and (len(e.args) > 0)  
and (e.args[0] == errno.EAGAIN):
                      got_timeout = True
+                elif self.__closed:
+                    raise EOFError()
                  else:
                      raise
              if got_timeout:




More information about the paramiko mailing list