0

I'm trying to connect celery to my django project via docker. But when starting the worker container, I get the following error -

File "/usr/local/lib/python3.13/site-packages/kombu/transport/redis.py", line 92, in <module>
 crit, warn = logger.critical, logger.warn
                               ^^^^^^^^^^^
 AttributeError: 'Logger' object has no attribute 'warn'

My requirements.txt file:

Django==4.2.7
psycopg==3.1.13
celery[redis]==5.3.6
django-celery-beat==2.5.0
redis==5.0.1

My dockerfile:

FROM python:3.13.0a1-alpine3.18

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements /temp/requirements
RUN apk add postgresql-client build-base postgresql-dev
RUN pip install -r /temp/requirements/local.txt

WORKDIR /myproject

COPY . .

EXPOSE 8000

My docker-compose.yml:

 redis:
    image: redis:7.2.3-alpine3.18
    ports:
      - '6379:6379'
    restart: always

  worker:
    build:
      context: .
    command: >
      sh -c "celery -A config worker -l INFO"
    restart: always
    depends_on:
      - redis

Structure of my project:

enter image description here

The src folder contains apps.

I tried to solve this problem but I failed. Please tell me what the problem might be and how to solve it. Thank you!

4
  • What python version are you using? The standard libs logging module allowed to use both, warn and warning, but warn is deprecated. Perhaps your python version doesn't support it anymore. Commented Nov 29, 2023 at 19:33
  • @erny, as far as I understood your question - i am using image python:3.13.0a1-alpine3.18. Commented Nov 29, 2023 at 20:03
  • logger.warn was removed in python 3.13. Use some previous version. Commented Nov 29, 2023 at 20:08
  • @erny, I used python version 3.12.0-alpine3.17 and it worked! Thank you very much! Commented Nov 29, 2023 at 20:14

1 Answer 1

0

Thanks to @erny I was able to solve this problem.

The problem was that in python 3.13 logger.warn was removed.

Therefore, in order for everything to work correctly at the moment of writing the answer, use python version up to 3.13 (not inclusive)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.