[paramiko] Check connection status

Robey Pointer robey at lag.net
Fri Nov 9 22:38:49 PST 2007


On Nov 6, 2007, at 10:19 AM, Pepe Barbe wrote:

> Hello everyone,
>
> I would like to know what will paramiko do if it is blocking on a recv
> request, given that there is no data to retrieve, and the connection
> drops. Will paramiko raise an Exception? Or do I have to frequently
> timeout and check if the connection is still up?

If the connection drops, the Channel should signal EOF, which will  
wake up any recv() and make it return with an empty string (which is  
python's way of indicating EOF). So you should be able to call recv()  
with no timeout if you wish.


> How can I check if a connection is still up? My guess is
> transport.is_authenticated but I am not sure.

Transport.is_active() is probably what you want.

robey




More information about the paramiko mailing list