From 1668ba7d9eb7aa4dcff3233e95195a8720cec162 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 29 Jun 2023 16:35:10 +0530 Subject: [PATCH] feat: Namespace all RQ jobs to site --- frappe/utils/background_jobs.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frappe/utils/background_jobs.py b/frappe/utils/background_jobs.py index 7de7ef6692..8254a6fb87 100755 --- a/frappe/utils/background_jobs.py +++ b/frappe/utils/background_jobs.py @@ -84,9 +84,8 @@ def enqueue( # To handle older implementations is_async = kwargs.pop("async", is_async) - if job_id: - # namespace job ids to sites - job_id = create_job_id(job_id) + # namespace job ids to sites + job_id = create_job_id(job_id) if job_name: deprecation_warning("Using enqueue with `job_name` is deprecated, use `job_id` instead.") @@ -481,6 +480,9 @@ def test_job(s): def create_job_id(job_id: str) -> str: """Generate unique job id for deduplication""" + + if not job_id: + job_id = str(uuid4()) return f"{frappe.local.site}::{job_id}"