Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 696097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:01:41+00:00 2026-05-14T03:01:41+00:00

This is related to my previous question , but a different one. I have

  • 0

This is related to my previous question, but a different one.

I have the following fabfile:

from fabric.api import *

host1 = '192.168.200.181'
offline_host2 = '192.168.200.199'
host3 = '192.168.200.183'

env.hosts = [host1, offline_host2, host3]
env.warn_only = True

def df_h():
    with settings(warn_only=True):
        run("df -h | grep sda3")

And the output is:

[192.168.200.199] run: df -h | grep sda3

Fatal error: Low level socket error connecting to host 192.168.200.199: No route to host

Aborting.

After the execution hits the offline server, it aborts immediately, regardless of the other servers in the env.hosts list.

I have used the env setting “warn_only=True”, but maybe I’m using it improperly.

How can I modify this behavior so that it will only prints the error and continue executing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:01:41+00:00Added an answer on May 14, 2026 at 3:01 am

    According to the Fabric documentation on warn_only,

    env.warn_only “specifies whether or not to warn, instead of abort, when run/sudo/local encounter error conditions.

    This will not help in the case of a server being down, since the failure occurs during the SSH attempt before executing run/sudo/local.

    One solution would be to create a function to check if each server is up prior to executing your tasks. Below is the code that I used.

    from __future__ import print_function
    from fabric.api import run, sudo, local, env
    import paramiko
    import socket
    
    host1 = '192.168.200.181'
    offline_host2 = '192.168.200.199'
    host3 = '192.168.200.183'
    
    env.hosts = [host1, offline_host2, host3]
    
    def df_h():
        if _is_host_up(env.host, int(env.port)) is True:
            run("df -h | grep sda1")
    
    
    def _is_host_up(host, port):
        # Set the timeout
        original_timeout = socket.getdefaulttimeout()
        new_timeout = 3
        socket.setdefaulttimeout(new_timeout)
        host_status = False
        try:
            transport = paramiko.Transport((host, port))
            host_status = True
        except:
            print('***Warning*** Host {host} on port {port} is down.'.format(
                host=host, port=port)
            )
        socket.setdefaulttimeout(original_timeout)
        return host_status
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related question to my previous question but different one. After searching a
This is related to my previous question but it is a different problem. I
This question is related to a previous question I asked, but it's a different.
This is related to my previous question , but it seems I have another
This is kind of related to my previous question, but not really. I have
This is related to a previous question , but it seems different enough to
Ok guys, this question is related to my previous one. If I have set
Very much related to my previous question , but I found this to be
This is related to my previous question , regarding pulling objects from a dmp
This question is related to my previous question . The storyline: I have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.