Code for testing working with celery, for future developments.
- Checkout thcheckout this article: Using Celery With Flask
- Python - A programming language.
- Flask - A microframework for Python.
- Virtualenv - A tool to create isolated virtual environments
- Docker is a work around to not having to install Redis
- Docker - set of platform as a service products that use OS-level virtualization to deliver software in packages called containers.
-
Clone or this download repo then 'cd' into the dir
-
Create virtual environment
virtualenv -p python3 venv
-
Create a '.env' file & add the following
touch .env
Add the following lines to the file
source venv/bin/activate export FLASK_APP=app.py export FLASK_DEBUG=1 export FLASK_ENV=development export CELERY_BROKER_URL='redis://0.0.0.0:6379/0' export CELERY_RESULT_BACKEND='redis://0.0.0.0:6379/0'
-
Create an instance dir & config.py file, add the following
mkdir instance && touch config.py
add the following
SECRET_KEY=<your value> MAIL_USERNAME=<your gmail username> MAIL_PASSWORD=<your gmail password>
-
Activate virtual environment & export variables
source .env
-
Install Dependancies.
pip install --no-cache-dir -r requirements.txt
-
Open the 3 terminal windows in the current dir
-
Start redis on one terminal
chmod +x run-redis.sh && ./run-redis.sh
-
Run celery worker on another terminal
celery worker -A app.celery --loglevel=info
-
Run flask app on the last window
flask run
- fun fact: minimise all windows to view changes in the windows.