Skip to content

Commit

Permalink
Fix worker error in macOS (getredash#6224)
Browse files Browse the repository at this point in the history
* Update worker.py
* fix
---------

Co-authored-by: rajat goyal <gyl.rajat@gmail.com>
  • Loading branch information
2 people authored and harveyrendell committed Jan 8, 2025
1 parent 17b39f7 commit 0ddd6f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions redash/tasks/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import errno
import os
import signal
import sys

from rq import Queue as BaseQueue
from rq.job import Job as BaseJob
Expand All @@ -10,9 +11,16 @@
from rq.worker import (
HerokuWorker, # HerokuWorker implements graceful shutdown on SIGTERM
)
from rq.worker import Worker

from redash import statsd_client

# HerokuWorker does not work in OSX https://github.com/getredash/redash/issues/5413
if sys.platform == "darwin":
BaseWorker = Worker
else:
BaseWorker = HerokuWorker


class CancellableJob(BaseJob):
def cancel(self, pipeline=None):
Expand Down Expand Up @@ -45,7 +53,7 @@ class RedashQueue(StatsdRecordingQueue, CancellableQueue):
pass


class StatsdRecordingWorker(HerokuWorker):
class StatsdRecordingWorker(BaseWorker):
"""
RQ Worker Mixin that overrides `execute_job` to increment/modify metrics via Statsd
"""
Expand All @@ -63,7 +71,7 @@ def execute_job(self, job, queue):
statsd_client.incr("rq.jobs.failed.{}".format(queue.name))


class HardLimitingWorker(HerokuWorker):
class HardLimitingWorker(BaseWorker):
"""
RQ's work horses enforce time limits by setting a timed alarm and stopping jobs
when they reach their time limits. However, the work horse may be entirely blocked
Expand Down

0 comments on commit 0ddd6f1

Please sign in to comment.