2929import random
3030import logging
3131import gevent
32- import threading
3332import paramiko
3433import os
3534import warnings
@@ -308,7 +307,7 @@ def test_pssh_client_long_running_command_exit_codes(self):
308307 msg = "Got non-zero exit code %s" % (
309308 output [self .host ]['exit_code' ],))
310309 del client
311-
310+
312311 def test_pssh_client_retries (self ):
313312 """Test connection error retries"""
314313 listen_socket = make_socket (self .host )
@@ -327,7 +326,19 @@ def test_pssh_client_retries(self):
327326 % (num_tries , expected_num_tries ,))
328327 else :
329328 raise Exception ('No ConnectionErrorException' )
330-
329+
330+ def test_sftp_exceptions (self ):
331+ self .server .kill ()
332+ # Make socket with no server listening on it on separate ip
333+ host = '127.0.0.3'
334+ _socket = make_socket (host )
335+ port = _socket .getsockname ()[1 ]
336+ client = ParallelSSHClient ([self .host ], port = port , num_retries = 1 )
337+ cmds = client .copy_file ("test" , "test" )
338+ client .pool .join ()
339+ for cmd in cmds :
340+ self .assertRaises (ConnectionErrorException , cmd .get )
341+
331342 def test_pssh_copy_file (self ):
332343 """Test parallel copy file"""
333344 test_file_data = 'test'
@@ -348,7 +359,7 @@ def test_pssh_copy_file(self):
348359 for filepath in [local_filename , remote_filename ]:
349360 os .unlink (filepath )
350361 del client
351-
362+
352363 def test_pssh_client_directory (self ):
353364 """Tests copying directories with SSH client. Copy all the files from
354365 local directory to server, then make sure they are all present."""
@@ -378,7 +389,7 @@ def test_pssh_client_directory(self):
378389 self .assertTrue (os .path .isfile (path ))
379390 shutil .rmtree (local_test_path )
380391 shutil .rmtree (remote_test_path )
381-
392+
382393 def test_pssh_pool_size (self ):
383394 """Test setting pool size to non default values"""
384395 hosts = ['host-%01d' % d for d in xrange (5 )]
0 commit comments