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

List running workers #88

Open
moi90 opened this issue Jun 29, 2019 · 1 comment
Open

List running workers #88

moi90 opened this issue Jun 29, 2019 · 1 comment

Comments

@moi90
Copy link

moi90 commented Jun 29, 2019

Is there a way to get a list of all currently running workers?

@AlexanderPashuk
Copy link

AlexanderPashuk commented Aug 13, 2019

Hey,

Check out https://github.com/eoranged/rq-dashboard. Very useful to monitor RQ.

Assume that we have initialized RQ and app:

# Initialization part
from flask import Flask
from flask_rq2 import RQ

app = Flask(__name__)
rq = RQ()

rq.init_app(rq)

To get all workers:

from rq import Worker
from rq.utils import import_attribute

# For default Worker class from RQ module:
workers = Worker.all(connection=rq.connection)

# For any Worker class
workers = import_attribute(rq.worker_class).all(connection=rq.connection)

(Additionally) To get list of workers for specified queue:

workers = Worker.all(queue=rq.get_queue('default'))
# or
workers = import_attribute(rq.worker_class).all(queue=rq.get_queue('default'))

Let me now if you need more info :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants