Skip to content

Instantly share code, notes, and snippets.

@sinkers
Created August 25, 2014 05:04
Show Gist options
  • Save sinkers/fac6da1475dc49c038ac to your computer and use it in GitHub Desktop.
Save sinkers/fac6da1475dc49c038ac to your computer and use it in GitHub Desktop.
Simple task submission to Celery
# 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