Skip to content

List running workers #88

Open
Open

Description

@moi90

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

Activity

  1. AlexanderPashuk commented on Aug 13, 2019

    @AlexanderPashuk

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions