Skip to content

Commit

Permalink
can't add to primary_worker_locks if it doesn't exist (#2903)
Browse files Browse the repository at this point in the history
* can't add to primary_worker_locks if it doesn't exist

* move init
  • Loading branch information
rkuo-danswer authored Oct 24, 2024
1 parent 33eabf1 commit bde446e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/danswer/background/celery/apps/primary.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:

logger.info("Running as the primary celery worker.")

sender.primary_worker_locks = {}

# This is singleton work that should be done on startup exactly once
# by the primary worker
tenant_ids = get_all_tenant_ids()
Expand Down Expand Up @@ -106,6 +108,7 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:
logger.error("Primary worker lock: Acquire failed!")
raise WorkerShutdown("Primary worker lock could not be acquired!")

# tacking on our own user data to the sender
sender.primary_worker_locks[tenant_id] = lock

# As currently designed, when this worker starts as "primary", we reinitialize redis
Expand Down

0 comments on commit bde446e

Please sign in to comment.