# Celery process terminated when same callback triggered multiple times

**URL:** <https://community.plotly.com/t/celery-process-terminated-when-same-callback-triggered-multiple-times/82105>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [February 5, 2024, 2:07pm UTC](https://community.plotly.com/t/celery-process-terminated-when-same-callback-triggered-multiple-times/82105 "2024-02-05T14:07:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthurJacquemart](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arthurJacquemart](https://community.plotly.com/u/arthurJacquemart)\
**Post date:** [February 5, 2024, 2:07pm UTC](https://community.plotly.com/t/celery-process-terminated-when-same-callback-triggered-multiple-times/82105/1 "2024-02-05T14:07:32Z")

</div>

Hi Dash community!

I am trying to run multiple times the same background callback.

Here is the expected behaviour:

- The callback is triggered every time the user click on a button.
- The callback takes a few seconds to execute.
- If the button is clicked again, before the first callback is finished, the callback will be triggered after the first callback has finished.

To do so, I tried to implement a **celery queue**.  
But I am facing an issue because every time I click on the button, it kills the previous processes, as you can see on the screenshot below:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/4/742c7602408057ced42bc745424d24e4c78d8af2.png)

I have tried to add pattern matching callback in order to “change” the callback ID but it didnt work.

Do you have an idea of a workaround? Or maybe there is something wrong I am doing?

Thank you for your time and help.

Arthur

---

<div class="post-metadata">

**Author:** ![gepo](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gepo](https://community.plotly.com/u/gepo)\
**Post date:** [June 10, 2025, 10:06am UTC](https://community.plotly.com/t/celery-process-terminated-when-same-callback-triggered-multiple-times/82105/2 "2025-06-10T10:06:31Z")

</div>

Adding an uuid to the `cache_by` argument in `CeleryManager` fixed the issue for me.  
This makes sure that a unique `cacheKey` is created for every request. [Background Callback Caching | Dash for Python Documentation | Plotly](https://dash.plotly.com/background-callback-caching)  
However, this effectively disables any caching for the whole `CeleryManager` instance.

```auto
from uuid import uuid4

celery_app = Celery( __name__ , broker=os.environ['REDIS_URL'], backend=os.environ['REDIS_URL'])
background_callback_manager = CeleryManager(celery_app, cache_by=[lambda: uuid4()])

```
