Skip to content

Commit

Permalink
Update to Python 3.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nickjj committed Dec 9, 2023
1 parent 03e30b0 commit 21189ac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ Changelog](https://keepachangelog.com/en/1.0.0/).

- Convert `SECRET_KEY` into a required env var
- Add `required: false` to `depends_on` in `docker-compose.yml` (requires Docker Compose v2.20.2+)
- Refactor `create_celery_app` function to be compatible with Python 3.12+

#### Languages and services

- Update `Python` to `3.11.6`
- Update `Python` to `3.12.1`
- Update `Node` to `20.6.1`
- Update `Postgres` to `16.1`
- Update `Redis` to `7.2.3`
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CMD ["bash"]

###############################################################################

FROM python:3.11.6-slim-bookworm AS app
FROM python:3.12.1-slim-bookworm AS app
LABEL maintainer="Nick Janetakis <nick.janetakis@gmail.com>"

WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ practices](https://nickjanetakis.com/blog/best-practices-around-production-ready
based on building and deploying dozens of assorted Dockerized web apps since
late 2014.

**This app is using Flask 3.0.0 and Python 3.11.6**. The screenshot doesn't get
**This app is using Flask 3.0.0 and Python 3.12.1**. The screenshot doesn't get
updated every time I bump the versions:

[![Screenshot](.github/docs/screenshot.jpg)](https://github.com/nickjj/docker-flask-example/blob/main/.github/docs/screenshot.jpg?raw=true)
Expand Down
18 changes: 8 additions & 10 deletions hello/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from celery import Celery
from celery import Task
from flask import Flask
from werkzeug.debug import DebuggedApplication
from werkzeug.middleware.proxy_fix import ProxyFix
Expand All @@ -20,18 +21,15 @@ def create_celery_app(app=None):
"""
app = app or create_app()

celery = Celery(app.import_name)
celery.conf.update(app.config.get("CELERY_CONFIG", {}))
TaskBase = celery.Task

class ContextTask(TaskBase):
abstract = True

def __call__(self, *args, **kwargs):
class FlaskTask(Task):
def __call__(self, *args: object, **kwargs: object) -> object:
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
return self.run(*args, **kwargs)

celery.Task = ContextTask
celery = Celery(app.import_name, task_cls=FlaskTask)
celery.conf.update(app.config.get("CELERY_CONFIG", {}))
celery.set_default()
app.extensions["celery"] = celery

return celery

Expand Down

0 comments on commit 21189ac

Please sign in to comment.