脚本完成后python垃圾收集时出现奇怪的线程错误

时间:2015-04-22 06:19:57

标签: python exception paramiko python-multithreading

我有一个python脚本,它同时使用多个SSH链接到多个远程服务器。有时当脚本完成时,我认为在垃圾收集期间,我遇到了这个例外:

Exception in thread Thread-7 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1574, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'
Exception in thread Thread-5 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1574, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'
Exception in thread Thread-4 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1574, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1574, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'error'

我用Google搜索Exception in thread Thread-7 (most likely raised during interpreter shutdown),我发现有时在多线程脚本中杀死线程会导致此异常。这对我来说真的很奇怪,因为我的脚本中没有线程。另一方面,它似乎与paramiko有关,而且我非常确定我不会使用线程来创建SSH链接;我只有多个打开的shell到多个服务器(可能有多个shell连接到一个特定的服务器)。关于异常来源的任何想法??

1 个答案:

答案 0 :(得分:2)

这似乎是Paramiko中的已知错误,请参阅:https://github.com/paramiko/paramiko/issues/17