forked from celery/django-celery-results
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Reproduce | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
rep194: | ||
name: Reproduce #194 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: docker-compose up -d --build migrate celery-worker | ||
working-directory: reproduce/rep194 | ||
- run: docker-compose run --rm celery-worker -c "python -c 'from reproduce.rep194.celery_app import run; run()'" | ||
working-directory: reproduce/rep194 | ||
- run: sleep 5 | ||
shell: bash | ||
- run: docker-compose logs celery-worker | ||
working-directory: reproduce/rep194 |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.git | ||
.pytest_cache | ||
.tox | ||
build | ||
*.egg-info | ||
docs | ||
requirements | ||
t/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM python:3.9.9-slim | ||
|
||
RUN pip install -U pip \ | ||
pip install django==3.* celery[redis] psycopg2-binary | ||
|
||
WORKDIR /app | ||
|
||
ENTRYPOINT ["bash"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .celery_app import app as celery_app |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
|
||
from celery import Celery, group, chain | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reproduce.rep194.settings') | ||
|
||
app = Celery('proj') | ||
|
||
# Using a string here means the worker doesn't have to serialize | ||
# the configuration object. | ||
app.config_from_object('django.conf:settings', namespace='CELERY') | ||
|
||
app.autodiscover_tasks() | ||
|
||
|
||
@app.task(name="task_0") | ||
def task_0(): | ||
return "Task 0" | ||
|
||
@app.task(name="task_1") | ||
def task_1(): | ||
return "Task 1" | ||
|
||
@app.task(name="task_2.1") | ||
def task_2_1(): | ||
return "Task 2.1" | ||
|
||
@app.task(name="task_2.2") | ||
def task_2_2(): | ||
return "Task 2.2" | ||
|
||
@app.task(name="task_2", bind=True) | ||
def task_2(self): | ||
return self.replace(group(task_2_1.si(), task_2_2.si())) | ||
|
||
@app.task(name="task_3") | ||
def task_3(): | ||
return "Task 3" | ||
|
||
@app.task(name="task_4") | ||
def task_4(): | ||
return "Task 4" | ||
|
||
@app.task(name="task_5") | ||
def task_5(): | ||
return "Task 5" | ||
|
||
@app.task(name="task_6") | ||
def task_6(): | ||
return "Task 6" | ||
|
||
@app.task(name="task_7") | ||
def task_7(): | ||
return "Task 7" | ||
|
||
def run(): | ||
import django | ||
django.setup() | ||
group( | ||
task_0.si(), | ||
chain( | ||
task_1.si(), | ||
group( | ||
task_2.si(), | ||
chain( | ||
task_3.si(), | ||
task_4.si(), | ||
task_5.si(), | ||
task_6.si(), | ||
) | ||
), | ||
task_7.si() | ||
) | ||
).delay() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
POSTGRES_PASSWORD=devpass | ||
DJANGO_SETTINGS_MODULE=reproduce.rep194.settings |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
version: '3.9' | ||
services: | ||
|
||
migrate: | ||
image: &image django-celery-results:latest | ||
build: | ||
context: ../.. | ||
dockerfile: reproduce/rep194/Dockerfile | ||
env_file: | ||
- defaults.env | ||
depends_on: | ||
- postgres | ||
- redis | ||
volumes: | ||
- ../..:/app | ||
command: -c "python manage.py migrate" | ||
|
||
celery-worker: | ||
image: *image | ||
depends_on: | ||
- redis | ||
- migrate | ||
env_file: | ||
- defaults.env | ||
volumes: | ||
- ../..:/app | ||
command: -c "celery -A reproduce.rep194 worker -l info" | ||
|
||
# Supporting services | ||
postgres: | ||
image: postgres:12.2-alpine | ||
restart: always | ||
volumes: | ||
- dbdata:/var/lib/postgresql/data | ||
env_file: | ||
- defaults.env | ||
|
||
redis: | ||
image: redis:alpine | ||
restart: always | ||
|
||
volumes: | ||
dbdata: |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from t.proj.settings import * | ||
|
||
CELERY_BROKER_URL = "redis://redis:6379/0" | ||
CELERY_RESULT_BACKEND = "django_celery_results.backends.database.DatabaseBackend" | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.postgresql', | ||
'HOST': 'postgres', | ||
'NAME': 'postgres', | ||
'USER': 'postgres', | ||
'PASSWORD': 'devpass', | ||
'OPTIONS': { | ||
'connect_timeout': 1000, | ||
} | ||
}, | ||
} |