Why in python3 paramiko hangs?

In some cases (in which - not established, slozhnokomponentnymi))hangs in this line:
ssh.connect(target, port = sshpo
def connect(target, sshport, user, password):
 ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
 ssh.connect(target, port = sshport, username = user, password = password, timeout=5, banner_timeout = 5, auth_timeout=5)
 resultCode = 1
 except paramiko.AuthenticationException:
 resultCode = 0
 except socket.error:
 resultCode = 2
April 3rd 20 at 17:44
1 answer
April 3rd 20 at 17:46
Try to add
try:
...
finnaly:
 ssh.close()

docs.paramiko.org/en/2.6/api/client.html#paramiko....
ssh.close in the code is, but it is not.
In some cases, ( ... ) hangs in this line:the line:
ssh.connect(target, port = sshpo

That is, if you dobaviti print'you:
print("PRINT 1")
ssh.connect(target, port = sshport, username = user, password = password, timeout=5, banner_timeout = 5, auth_timeout=5)
print("PRINT 2")

PRINT 1 will be printed, PRINT 2 no - rachael9 commented on April 3rd 20 at 17:49
It can be and if the server has too many open incoming connectinos and the server hangs when opening a new
It is therefore important to put close in the finally - Jany58 commented on April 3rd 20 at 17:52
@Kevin39, he stood in finaly. Just stroke not copied - rachael9 commented on April 3rd 20 at 17:55

Find more questions by tags PythonSSH