为什么sshtunnel会阻止SIGINT关闭我的python应用程序?

时间:2016-04-16 12:28:19

标签: python ssh

如果您使用这一小段代码:

import sshtunnel

# The IP of any system with an SSH server on port 22
ip = "localhost"

print "Connecting to ssh..."
with sshtunnel.open_tunnel(ip, ssh_username="test",
                           ssh_password="test",
                           remote_bind_address=("1.2.3.4", 23)) as server:

    print "SSH connected"

print "SSH Closed"

将“ip”变量设置为在端口22上运行SSH服务器的任何系统,运行代码,并在打印“正在连接到ssh ...”后尝试使用Ctrl + C中断它,它将给你追溯并冻结(不退出)。 是什么阻碍了它?

1 个答案:

答案 0 :(得分:1)

目前DF$a没有考虑任何信号。 您可以通过运行以下方法解决:

sshtunnel