Skip to content

Commit

Permalink
use rq_redis_connection instead of redis_connection (#4288)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Lachish authored and arikfr committed Oct 25, 2019
1 parent 7157244 commit ba413c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions redash/monitor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import
import itertools
from sqlalchemy import union_all
from redash import redis_connection, __version__, settings
from redash import redis_connection, rq_redis_connection, __version__, settings
from redash.models import db, DataSource, Query, QueryResult, Dashboard, Widget
from redash.utils import json_loads
from redash.worker import celery
Expand Down Expand Up @@ -36,7 +36,7 @@ def get_celery_queues():

def get_queues_status():
return {**{queue: {'size': redis_connection.llen(queue)} for queue in get_celery_queues()},
**{queue.name: {'size': len(queue)} for queue in Queue.all(connection=redis_connection)}}
**{queue.name: {'size': len(queue)} for queue in Queue.all(connection=rq_redis_connection)}}


def get_db_sizes():
Expand Down Expand Up @@ -141,7 +141,7 @@ def fetch_jobs(queue, job_ids):
'queue': queue.name,
'enqueued_at': job.enqueued_at,
'started_at': job.started_at
} for job in Job.fetch_many(job_ids, connection=redis_connection) if job is not None]
} for job in Job.fetch_many(job_ids, connection=rq_redis_connection) if job is not None]


def rq_queues():
Expand All @@ -150,7 +150,7 @@ def rq_queues():
'name': q.name,
'started': fetch_jobs(q, StartedJobRegistry(queue=q).get_job_ids()),
'queued': len(q.job_ids)
} for q in Queue.all(connection=redis_connection)}
} for q in Queue.all(connection=rq_redis_connection)}


def describe_job(job):
Expand All @@ -170,7 +170,7 @@ def rq_workers():
'successful_jobs': w.successful_job_count,
'failed_jobs': w.failed_job_count,
'total_working_time': w.total_working_time
} for w in Worker.all(connection=redis_connection)]
} for w in Worker.all(connection=rq_redis_connection)]


def rq_status():
Expand Down
4 changes: 2 additions & 2 deletions redash/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
from rq import get_current_job
from rq.decorators import job as rq_job

from redash import create_app, extensions, settings, redis_connection
from redash import create_app, extensions, settings, redis_connection, rq_redis_connection
from redash.metrics import celery as celery_metrics # noqa

logger = get_logger(__name__)

job = partial(rq_job, connection=redis_connection)
job = partial(rq_job, connection=rq_redis_connection)


class CurrentJobFilter(logging.Filter):
Expand Down

0 comments on commit ba413c2

Please sign in to comment.