Error handling with @parallel decorator

Ankur Agrawal ankur.cse at gmail.com
Mon Jan 18 01:15:24 EST 2016


I am trying to catch Abort exception. When I use fabric's run(...) method,
the host it tries to connect is not available and so it aborts with connect
time out exception. I am not able to catch it. Following is a two different
ways of code snippet-
First I try following  -

class FabricException(Exception):
    pass

with settings(abort_exception = FabricException):

try:
    output = run(command)
except FabricException:
    print 'inside exception'
    LOG.debug("inside exception")

It didn't go in exception block. Instead it threw -
NetworkError: Timed out trying to connect to pqaltsnas300.corp.intuit.net
(tried 1 time)
Aborting.
SystemExit: 1

Then I try to continue even if exception -
command  = 'ls -l'
with settings(warn_only = True):
      output = run(command)

Still it threw the same exception
NetworkError: Timed out trying to connect to pqaltsnas300.corp.intuit.net
(tried 1 time)
Aborting.
SystemExit: 1

Appreciate if somebody tell if I am missing anything ?

Thanks,
Ankur



More information about the Python-list mailing list