fabric Socket异常:连接超时

时间:2013-07-06 01:33:51

标签: python fabric

有时我的Fabric脚本运行时基本上在远程计算机上运行几个命令,我遇到了这个错误:

ERROR:paramiko.transport:Socket exception: Connection timed out (110)
!!! Parallel execution exception under host 'xyz'
....
....      (several logs here)
error: [Errno 110] Connection timed out

我的代码是这样的:

with settings(....):
    execute(tasks,...)

有没有办法使用哪个结构可以重试旧命令,而不是在遇到这样的超时时跳过它,例如可以选择在上面的设置中重试?

1 个答案:

答案 0 :(得分:0)

使用Fabric 1.4+,在命令行上使用env.connection_attempts参数或类似标志。

<强> Multiple connection attempts and skipping bad hosts

  

从Fabric 1.4开始,   可能会多次尝试连接到远程服务器   中止错误:Fabric将尝试连接   env.connection_attempts放弃之前的时间,超时时间   每次env.timeout秒。 (这些目前默认为1试试和   10秒,以匹配以前的行为,但他们可以安全地更改   无论你需要什么。)

来自http://docs.fabfile.org/en/latest/usage/execution.html#multiple-connection-attempts-and-skipping-bad-hosts