第二次导入后,ftp上的Python Streamhandler无效

时间:2013-11-11 07:03:57

标签: python logging ftp paramiko

我有以下问题:

我编写了一个FTPHandler(StreamHandler),它通过'transport = paramiko.Transport(...)'和'transport.connect(...)'连接到服务器并打开与'SFTPClient.from_transport的sftp连接(...)”

我在名为'JUS_Logger.py'的类中导入此处理程序,这是我的日志记录模块。这个'FMP_Logger'由另一个类'JUS_Reader'导入。

问题是,如果我启动'JUS_Reader',传输正在初始化,但连接失败。没有例外,该程序只挂起。如果我杀了它,我会得到堆栈跟踪

CTraceback (most recent call last):
  File "./JUS_Reader.py", line 24, in <module>
    from JUS_Logger import logger
  File "/<home>/.../JUS_Logger.py", line 74, in <module>
    ftpHandler=FTPHandler(ftpOut,10)
  File "/<home>/FTPHandler.py", line 21, in __init__
        self.transport.connect(username=ftpOut['user'].decode('base64'),password=ftpOut['passwd'].decode('base64'))
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1004, in connect
    self.auth_password(username, password)
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1165, in auth_password
    return self.auth_handler.wait_for_response(my_event)
  File "/usr/lib/python2.7/dist-packages/paramiko/auth_handler.py", line 158, in wait_for_response
    event.wait(0.1)
  File "/usr/lib/python2.7/threading.py", line 403, in wait
    self.__cond.wait(timeout)
  File "/usr/lib/python2.7/threading.py", line 262, in wait
    _sleep(delay)

但是,如果我自己运行'JUS_Logger.py',一切正常,传输的连接建立,SFTClient也连接。

有什么想法吗?或者进一步的问题?

0 个答案:

没有答案