【发布时间】:2020-03-25 14:55:08
【问题描述】:
我有一个创建 AWS 实例并使用 fabric==2.5.0 配置它们的脚本。这是我在脚本中使用 fabric2 Connection 实例的问题:
def setup_site(self, ip, name):
connection = Connection(ip, user='toolman')
# If I put ipdb here, just continuing it will work.
# If take the debug line out, it will fail
# with "NoValidConnectionsError: [Errno None] Unable to connect to port 22 on ..."
# import ipdb; ipdb.set_trace()
connection.put(self.create_setup_file(name), 'setup.yaml')
我可以点击“c”继续调试器,每次都一切正常。如果我没有调试器线,connection.put 调用每次都会失败,并显示“NoValidConnectionsError: [Errno None] Unable to connect to port 22 on ...”。
将文件放入的 AWS 实例正在运行(instance.wait_until_running() 在调用 setup_site 的代码中返回)。
【问题讨论】:
-
您可能需要调用
connection.open()来初始化连接 - docs.fabfile.org/en/2.5/api/… -
我会尝试,但我不需要在发生 ipdb 中断的情况下这样做
标签: python amazon-web-services amazon-ec2 fabric