How I can debug a code that is runnig in rabbitmq-celery pipeline in docker-compose remote debug configuration?

I am thinking about purchasing Professional PyCharm edition and the only feature I really need is remote debug in container.

I have an app broken into services. Backend, which I want to debug is a Flask service that is running in separate container.

I am able to debug Flask app but debugger can't follow the code that was put into rabbit queue in this manner

process_message.delay(...)

@queue.task(queue="process-message", base=ProcessMessageTask)
def process_message(...)

 

The queue is handled by Celery which initially was running in separate container along with rabbitmq, so I put all the stuff in one container and also forced Celery to run in current thread, but I still can't get debugger to go into queued tasks.

My questions is how can I configure my debugger and if this possible to do so?

This is docker-compose configuration for app, so I use debugger from this docker-compose configuration.

version: '3'
services:
api:
build: api/
ports:
- 8000:8000
env_file: api/.env
volumes:
- api-rsync:/usr/src/app:nocopy
links:
- mongo
- redis
- rabbitmq
depends_on:
- mongo
- redis
- rabbitmq
command: celery worker -A queue_conf -P eventlet -c 4 -l INFO -Q emit,high,low,normal,process-message -n worker --without-gossip --without-mingle --without-heartbeat

With code below I tried to configure Celery to run in one thread

current_app.conf.CELERY_ALWAYS_EAGER = True
current_app.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
2

Please sign in to leave a comment.