[paramiko] Paramiko's leaking file descriptors
Robey Pointer
robey at lag.net
Mon Nov 20 11:21:55 PST 2006
On 19 Nov 2006, at 5:47, David Guerizec wrote:
> Hello,
>
> I've been trying to optimize file descriptors utilisation in
> sshproxy, and I
> found that paramiko is leaking file descriptors when using
> Channel.fileno()
> method.
>
> What is happening is when calling fileno(), a pipe object is
> created, using 2
> file descriptors, but when a channel is closed by the remote side
> (that is
> not explicitly by calling Channel.close()), the pipe's FDs are not
> closed but
> the paramiko Pipe object is doing like so, by setting self._forever.
>
> I've made a patch (attached to this message) to close these file
> descriptors
> when the Pipe.set_forever() method is called, and that seems to fix my
> problem.
I think I see the underlying bug: when the remote host closes a
channel first, the section of close() that closes the pipe is never
reached. (close() is always called eventually, since it's invoked by
__del__.) I've re-ordered the close() sequence in change 416 -- does
that fix it?
robey
More information about the paramiko
mailing list