Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rq_redis_connection instead of redis_connection #4288

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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