From a0762e28357b31e5ab91abb280ce8e312b96d650 Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Wed, 8 May 2024 16:32:10 +0200 Subject: [PATCH] celery delay repro https://github.com/getsentry/sentry-python/issues/687 --- python/celery/app.py | 4 ++-- python/celery/celapp.py | 21 ++++++++++++++++++--- python/celery/requirements.txt | 21 ++++++++++++--------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/python/celery/app.py b/python/celery/app.py index 9d97b37..ee54ca1 100644 --- a/python/celery/app.py +++ b/python/celery/app.py @@ -1,3 +1,3 @@ -from tasks import task, try_dividing_by_zero +from celapp import my_task -try_dividing_by_zero.delay() +my_task.delay() diff --git a/python/celery/celapp.py b/python/celery/celapp.py index b9d62be..6cad088 100644 --- a/python/celery/celapp.py +++ b/python/celery/celapp.py @@ -1,5 +1,15 @@ -from celery import Celery, signals +import logging +import time import sentry_sdk +from secrets import token_hex +from celery import Celery, signals + + +def init_sentry(): + sentry_sdk.init(debug=True) + + +# init_sentry() app = Celery( @@ -8,11 +18,16 @@ include=['tasks'], ) +logger = logging.getLogger(__name__) +logger.error(f"SETUP {token_hex(2)}") -def init_sentry(): - sentry_sdk.init(traces_sample_rate=1.0, debug=True) + +@app.task +def my_task(): + logger.error(f"MY_TASK {token_hex(2)}") @signals.celeryd_init.connect +# @signals.worker_init.connect def init_worker(**_kwargs): init_sentry() diff --git a/python/celery/requirements.txt b/python/celery/requirements.txt index cede131..342d1ca 100644 --- a/python/celery/requirements.txt +++ b/python/celery/requirements.txt @@ -1,17 +1,20 @@ -amqp==5.1.1 -billiard==4.1.0 -celery==5.3.3 +-e git+ssh://git@github.com/getsentry/sentry-python.git@7a7867b2fe0ad8b3d7aeea778b2992b1c506509d#egg=sentry_sdk +amqp==5.2.0 +async-timeout==4.0.3 +billiard==4.2.0 +celery==5.3.5 certifi==2023.7.22 click==8.1.7 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.3.0 -kombu==5.3.2 -prompt-toolkit==3.0.39 +kombu==5.3.3 +prompt-toolkit==3.0.41 python-dateutil==2.8.2 --e git+ssh://git@github.com/getsentry/sentry-python.git@7a7867b2fe0ad8b3d7aeea778b2992b1c506509d#egg=sentry_sdk +redis==5.0.1 six==1.16.0 +typing_extensions==4.8.0 tzdata==2023.3 -urllib3==2.0.4 -vine==5.0.0 -wcwidth==0.2.6 +urllib3==2.1.0 +vine==5.1.0 +wcwidth==0.2.10