zhengrui315 / flask-celery-redis-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redis Demo

This is a demo flask app using celery as the task queue together with redis as the broker, the in-memory storage.

how to run in mac

  • install redis
$ wget http://download.redis.io/releases/redis-6.0.5.tar.gz
$ cd ~/Downloads
$ tar xzf redis-6.0.5.tar.gz
$ cd redis-6.0.5
$ make

$ make test # this is for testing
$ src/redis-server # start redis server
$ src/redis-cli # start the redis CLI

We can also copy the redis commands to /user/local/bin so they can be started in any directory

$ sudo cp src/redis-server /usr/local/bin/
$ sudo cp src/redis-cli /usr/local/bin/
  • create virtual env
$ virtualenv -p python3 venv
$ source venv/bin/activate
  • start the flask app
(venv) $ python redisdemo.py
  • start celery, check the execution of the tasks
(venv) $ celery -A redisdemo worker

About


Languages

Language:Python 100.0%