File tree 3 files changed +24
-3
lines changed
changelog/entries/unreleased/bug
3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 1
- from celery import Celery
1
+ from celery import Celery , signals
2
+
3
+ from baserow .core .cache import local_cache
2
4
3
5
app = Celery ("baserow" )
4
6
app .config_from_object ("django.conf:settings" , namespace = "CELERY" )
5
7
app .autodiscover_tasks ()
8
+
9
+
10
+ def clear_local_cache (* args , ** kwargs ):
11
+ """
12
+ Clear the thread-local cache before and after each Celery task to prevent
13
+ data leakage between tasks running on the same worker thread.
14
+ """
15
+
16
+ local_cache .clear ()
17
+
18
+
19
+ signals .task_prerun .connect (clear_local_cache )
20
+ signals .task_postrun .connect (clear_local_cache )
Original file line number Diff line number Diff line change 3
3
from django .conf import settings
4
4
5
5
from baserow .config .celery import app
6
- from baserow .core .cache import local_cache
7
6
from baserow .core .jobs .exceptions import JobCancelled
8
7
from baserow .core .jobs .registries import job_type_registry
9
8
from baserow .core .sentry import setup_user_in_sentry
15
14
queue = "export" ,
16
15
soft_time_limit = settings .BASEROW_JOB_SOFT_TIME_LIMIT ,
17
16
)
18
- @local_cache .context ()
19
17
def run_async_job (self , job_id : int ):
20
18
"""Run the job task asynchronously"""
21
19
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " bug" ,
3
+ "message" : " Clear local_cache for celery tasks" ,
4
+ "domain" : " core" ,
5
+ "issue_number" : 3528 ,
6
+ "bullet_points" : [],
7
+ "created_at" : " 2025-03-26"
8
+ }
You can’t perform that action at this time.
0 commit comments