mam*_*mcx 11 python ssh paramiko
我有一个使用paramiko的自动化过程并出现此错误:
Exception in thread Thread-1 (most likely raised during interpreter
shutdown)
....
....
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute
'error'
Run Code Online (Sandbox Code Playgroud)
我知道这是清理/线程中的问题,但我不知道如何解决它.
我有最新版本(1.7.6)并根据此线程,它已解决,所以我直接下载代码但仍然得到错误.
在winxp/win2003下的Python 2.5/2.6上发生了故障.
我在__del__析构函数中关闭连接,然后在脚本结束之前关闭它,这些都不起作用.还有更多,使用这个错误发生在前面,所以也许与解释器关闭无关?
__del__不是解构主义者.当你删除一个对象的姓氏时会调用它,当你退出解释器时它不会发生.
任何管理上下文的东西,例如连接,都是context manager例如closing:
with closing(make_connection()) as conn:
dostuff()
# conn.close() is called by the `with`
Run Code Online (Sandbox Code Playgroud)
无论如何,发生这种异常是因为你有一个守护程序线程在解释器已经关闭时仍然试图完成它的工作.
我认为你只能通过编写在退出之前停止所有正在运行的线程的代码来解决这个问题.