Paramiko hanging during authentication, when runned by dint of unittest runner

最后都变了- 提交于 2019-12-02 01:42:36

问题


Good day.

I have a strange problem with paramiko ssh client. Connect paramiko method hangs when it's called outside unittest2 classes/functions and code was run by unittest runner.

There is a piece of code, where problem appears:

import paramiko
import unittest2

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('172.18.67.10',
            username='root',
            password='secrete')
_, stdout, _ = ssh.exec_command('date')


class TestTest(unittest2.TestCase):
    def setUp(self):
        pass

If I move ssh.connect into TestTest class or setUpModule function, connection will be successful. Also everything is OK when code is run by original Python interpreter.

When I try to debug paramiko, I figure out this problem inside while True loop in paramiko/auth_handler.py:AuthHandler.wait_for_response method.

Any suggestions?


回答1:


According to this SO answer, it seems to be a thread-related bug in paramiko and can be avoided by not calling connect() during import.



来源:https://stackoverflow.com/questions/13155890/paramiko-hanging-during-authentication-when-runned-by-dint-of-unittest-runner

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!