Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101870

Error handling with @parallel decorator

From Ankur Agrawal <ankur.cse@gmail.com>
Newsgroups comp.lang.python
Subject Error handling with @parallel decorator
Date 2016-01-18 06:15 +0000
Message-ID <mailman.85.1453097737.15297.python-list@python.org> (permalink)
References <CAOQEriym0_yZyUhmXR=kr8C52j3r0pSbC4Gp9Y7CbjFrrQB_8Q@mail.gmail.com>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Error handling with @parallel decorator Ankur Agrawal <ankur.cse@gmail.com> - 2016-01-18 06:15 +0000
  Re: Error handling with @parallel decorator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-18 18:10 +1100
    Re: Error handling with @parallel decorator Ankur Agrawal <ankur.cse@gmail.com> - 2016-01-19 15:01 +0000

csiph-web