Created
August 25, 2014 05:04
-
-
Save sinkers/fac6da1475dc49c038ac to your computer and use it in GitHub Desktop.
Simple task submission to Celery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First part is a unit test script effectively, this code would go in the Flask app | |
from celery import Celery | |
# There needs to be a seperate tasks module, see below | |
import tasks | |
# Celery uses redis to commuicate between tasks | |
celery = Celery("app", broker='redis://localhost:6379',backend='redis://localhost:6379') | |
# This submits the task to run via Celery | |
tasks.generate_app.s().apply_async() | |
# tasks.py | |
from celery import task, Celery | |
import subbprocess | |
celery = Celery("app", broker='redis://localhost:6379',backend='redis://localhost:6379') | |
@task() | |
def generate_app(params): | |
# Prob need some steps here to pass in parameters to generate | |
cmd = "whatever we need to run maven script with params" | |
process = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
so, se = process.communicate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment