From 0f7099c52744cfe653d1072d8dd3e4b49b2fc515 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sat, 29 Mar 2025 12:09:24 +0530 Subject: [PATCH] build: bump RQ to latest (#31952) perf fix for busy pubsub thread --- frappe/utils/background_jobs.py | 20 -------------------- pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/frappe/utils/background_jobs.py b/frappe/utils/background_jobs.py index 12897c7f96..2e1c8b5131 100644 --- a/frappe/utils/background_jobs.py +++ b/frappe/utils/background_jobs.py @@ -355,26 +355,6 @@ class FrappeWorker(Worker): Thread(target=start_scheduler, daemon=True).start() - def subscribe(self): - """Subscribe to this worker's channel""" - # This function is overridden to increase the timeout of pubsub thread. Default is 0.2 - # second which is too frequent for us, this change sets it to 2s which is 10x the default. - # ref: https://github.com/frappe/caffeine/issues/46 - - # The pubsub thread is responsible for handling three commands from master process: - # 1. shutdown - # 2. stop current job - # 3. Kill forked horse (~ force stop the job) - - # Impact of increasing timeout: shutdown might have up to 2s before background thread - # times out and is joined with main thread. Ideally, we should not have to do this at all. - # But the code that handles blocking socket behaviour is deep inside redis-py/hiredis. - - self.log.info("Subscribing to channel %s", self.pubsub_channel_name) - self.pubsub = self.connection.pubsub() - self.pubsub.subscribe(**{self.pubsub_channel_name: self.handle_payload}) - self.pubsub_thread = self.pubsub.run_in_thread(sleep_time=2, daemon=True) - class FrappeWorkerNoFork(FrappeWorker): def __init__(self, *args, **kwargs): diff --git a/pyproject.toml b/pyproject.toml index b6f47fc5b4..fa5e96a508 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ dependencies = [ # We depend on internal attributes of RQ. # Do NOT add loose requirements on RQ versions. # Audit the code changes w.r.t. background_jobs.py before updating. - "rq==2.1.0", + "rq==2.2.0", "rsa>=4.1", "semantic-version~=2.10.0", "sentry-sdk~=1.37.1",