Skip to content

Instantly share code, notes, and snippets.

@gedankenstuecke
Created November 22, 2017 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gedankenstuecke/cb20ce0b52a83248e80c5bf3cb16d33f to your computer and use it in GitHub Desktop.
Save gedankenstuecke/cb20ce0b52a83248e80c5bf3cb16d33f to your computer and use it in GitHub Desktop.
# get new directory for this
mkdir celery
cd celery
# create environment w/ py2.7
conda create -n celery python=2.7
# switch to environment
source activate celery
# install packages
brew install redis # getting redis on mac os
pip install celery
pip install redis
# start redis
redis-server
# write tasks.py
vim tasks.py
# from celery import Celery
#
# app = Celery('tasks', broker='redis://localhost',backend='redis://localhost')
#
# @app.task
# def add(x, y):
# return x + y
# now start celery worker
celery -A tasks worker --loglevel=info
# start python shell
python
# run the following inside:
# >>> from tasks import add
# >>> result = add.delay(4, 4)
# >>> result.ready()
# True
# >>> result
# <AsyncResult: f2a39668-ea2f-4f1d-9910-499a28bbc40d>
# >>> result.get()
8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment