fabric/fabric — Issue #572: Fabric returns exit code 0 on failed parallel tasks
Author: statico
Created: 2012-02-28 06:03:50+00:00
State: open

Given this `fabfile.py`:

from fabric.api import *

def test():
abort('whoops')

And the command:

$ fab test -H host1,host2 && echo yes || echo no

The result is:

Fatal error: whoops

Aborting.
[host1] Executing task 'foo'
no

Makes sene. However, if I run them in parallel using the `-P` flag or `@parallel` decorator:

[host1] Executing task 'foo'
[host2] Executing task 'foo'

Fatal error: whoops

Aborting.
!!! Parallel execution exception under host 'host1':
Traceback (most recent call last):
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 167, in inner
result = task.run(*args, **kwargs)
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 113, in run
return self.wrapped(*args, **kwargs)
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/decorators.py", line 178, in inner
return func(*args, **kwargs)
File "/tmp/temp.py", line 5, in foo
abort('whoops')
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/utils.py", line 26, in abort
sys.exit(1)
SystemExit: 1

Fatal error: whoops

Aborting.
!!! Parallel execution exception under host 'host0':
Traceback (most recent call last):
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 167, in inner
result = task.run(*args, **kwargs)
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 113, in run
return self.wrapped(*args, **kwargs)
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/decorators.py", line 178, in inner
return func(*args, **kwargs)
File "/tmp/temp.py", line 5, in foo
abort('whoops')
File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/utils.py", line 26, in abort
sys.exit(1)
SystemExit: 1

Done.
yes

Shouldn't fabric return non-zero if any of the subtasks failed? (I don't necessarily care about order, like [issue #457](https://github.com/fabric/fabric/issues/457))

Fabric is great, BTW. Keep up the fantastic work.