fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] How to mix the task and runs_once decorator


From: Jeff Dyke
Subject: Re: [Fab-user] How to mix the task and runs_once decorator
Date: Sat, 11 Jan 2014 12:37:32 -0500

I struggled with this for a bit as well, and the way i have approached this is to use execute inside the task you only want to run_once.  

from fabric.api import task,runs_once, execute

@task
@runs_once
def report_pending_updates():
   execute(check_for_updates)

   #report here

def check_for_updates():
  ...

HTH
Jeff


On Thu, Jan 9, 2014 at 3:17 PM, Chris Spencer <address@hidden> wrote:
How do you mix the @task and @runs_once decorator?

I have a task (check_for_updates) that checks installed Python packages on each host and records which ones need updates. I then have a task (report_pending_updates) that displays a report showing which hosts require updates. So I'm doing:

    fab production check_for_updates report_pending_updates

However, since I have multiple hosts, it runs report_pending_updates for each host, showing the report multiple times.

I've tried constructing my task like:

@runs_once
@task
def report_pending_updates():
    ...

but this causes Fabric to not detect the task. Switching the decorator order results in the same error.

Regards,
Chris

_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user



reply via email to

[Prev in Thread] Current Thread [Next in Thread]