python问题记录 - paramiko模块报错

文章目录

      • 报错关键字
      • 1. 代码
      • 2. 输出
      • 3. 报错信息
      • 4. 解决方案

报错关键字

  • paramiko
  • Exception ignored in: del at 0x109259820>
  • AttributeError: ‘NoneType’ object has no attribute ‘time’

1. 代码

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import paramiko
import sys

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.30.40.50', 22, 'root', 'fuck')
stdin, stdout, stderr = ssh.exec_command('ls -l /python/')
print(stdout.readlines())

2. 输出

/Users/zhanghao/code/python-learning/sysinfo/.venv/bin/python /Users/zhanghao/code/python-learning/sysinfo/utils/connect_remote_host.py
['total 0\n', 'drwxr-xr-x 3 root root 35 May 30 00:54 python\n']
Exception ignored in: <function BufferedFile.__del__ at 0x109259820>
Traceback (most recent call last):
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/file.py", line 66, in __del__
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/channel.py", line 1392, in close
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/channel.py", line 991, in shutdown_write
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/channel.py", line 967, in shutdown
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/transport.py", line 1846, in _send_user_message
AttributeError: 'NoneType' object has no attribute 'time'

Process finished with exit code 0

3. 报错信息

Exception ignored in: <function BufferedFile.__del__ at 0x109259820>
Traceback (most recent call last):
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/file.py", line 66, in __del__
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/channel.py", line 1392, in close
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/channel.py", line 991, in shutdown_write
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/channel.py", line 967, in shutdown
  File "/Users/zhanghao/code/python-learning/sysinfo/.venv/lib/python3.8/site-packages/paramiko/transport.py", line 1846, in _send_user_message
AttributeError: 'NoneType' object has no attribute 'time'

4. 解决方案

将代码最后添加一个sys.exit()程序恢复正常,但是具体原因还不清楚,感觉是paramiko模块的问题

你可能感兴趣的:(问题记录)