python通过ssh连接数据库提示端口类型问题

问题遇到的现象和发生背景

python通过跳板机连接数据库时,提示remote_bind_address的参数端口号必须是int类型,但实际已经传了int类型的端口了

代码如下

class Mysql:
    def __init__(self):
        self.log = my_log()
        db_data = ConfigYaml().get_db_data()
        db_port = 3301
        print("db_port类型",type(db_port))
        self.server = SSHTunnelForwarder(
            (db_data["DB_HOST"],db_data["ssh_port"]),
            ssh_username = db_data["ssh_username"],
            ssh_pkey = get_data_path() + "\.ssh\id_rsa",
            remote_bind_address=(db_data["addr"],db_port)
        )
        self.server.start()


运行结果及报错内容
Traceback (most recent call last):
db_port类型 'int'>
  File "D:/learn/HabibiActivities-New/utils/MysqlUtil.py", line 82, in 
    res = Mysql().fetchone(sql)
  File "D:/learn/HabibiActivities-New/utils/MysqlUtil.py", line 21, in __init__
    remote_bind_address=(db_data["addr"],db_port)
  File "C:\Users\46188\AppData\Local\Programs\Python\Python37\lib\site-packages\sshtunnel.py", line 931, in __init__
    check_address(ssh_address_or_host)
  File "C:\Users\46188\AppData\Local\Programs\Python\Python37\lib\site-packages\sshtunnel.py", line 110, in check_address
    check_port(address[1])
  File "C:\Users\46188\AppData\Local\Programs\Python\Python37\lib\site-packages\sshtunnel.py", line 85, in check_port
    assert isinstance(port, int), 'PORT is not a number'
AssertionError: PORT is not a number
Exception ignored in: <function Mysql.__del__ at 0x00000218C0945268>
Traceback (most recent call last):
  File "D:/learn/HabibiActivities-New/utils/MysqlUtil.py", line 73, in __del__
    if self.cursor is not None:
AttributeError: 'Mysql' object has no attribute 'cursor'

想问下各位,这是哪里出了问题

感觉问题会比较古怪,建议借助 ide 使用 debug 模式深入调用栈中查看。