New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`@parallel' decorator causes TypeError if it's not placed as the last decorator of a task #1068

Open
alb-i986 opened this Issue Feb 12, 2014 · 2 comments

Comments

Projects
None yet
4 participants
@alb-i986

alb-i986 commented Feb 12, 2014

While writing a task, I noticed that @parallel works only if it is placed as the last decorator of a task (just above def). I don't think it is the expected behavior, is it?

Affected versions (these are the ones I tried): 1.6.0, 1.7.0, 1.8.1

I'm on:

  • ubuntu precise 32bit
  • Python 2.7.3
  • Paramiko 1.12.1

Here is the task:

from fabric.api import *
from fabric.contrib import *

@parallel
@hosts('myhost')
@task
def vms_update():
  with settings(
    hide('warnings', 'running', 'stdout', 'stderr')
  ):
    sudo("aptitude update")
  sudo("aptitude upgrade")

Here is the output:

$ fab vms_update
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
    *args, **kwargs
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 405, in execute
    results['<local-only>'] = task.run(*args, **new_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
    return self.wrapped(*args, **kwargs)
TypeError: real_decorator() takes exactly 1 argument (0 given)

But everything's fine if @parallel is placed on the line before the task def:

@hosts('myhost')
@task
@parallel
def vms_update():
[..]
@nchammas

This comment has been minimized.

nchammas commented Mar 13, 2015

+1

I just ran into this as well and confirmed that moving @parallel to be the last decorator makes things work again.

@adaszko

This comment has been minimized.

adaszko commented Apr 29, 2015

Just encountered this myself too, so +1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment