Skip to content

Empty (i.e., {}) redbeat.schedulers.RedBeatScheduler.schedule #155

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

Open
gduverger opened this issue Mar 29, 2020 · 2 comments
Open

Empty (i.e., {}) redbeat.schedulers.RedBeatScheduler.schedule #155

gduverger opened this issue Mar 29, 2020 · 2 comments

Comments

@gduverger
Copy link

I am trying to get a list of all the RedBeat entries but the following code seems to always return {}:

import redbeat
scheduler = redbeat.schedulers.RedBeatScheduler(app=<my_celery_app>)
return scheduler.schedule

Is it expected? Is there another way to retrieve the list of tasks?

@tlinhart
Copy link

I end up using this to get a list of RedBeat entries:

from pprint import pprint
from celery import Celery
from redbeat import schedulers

app = Celery(broker='amqp://myuser:mypassword@myhost:5672/celery')
app.conf.update({
    'redbeat_redis_url': 'redis://:mypassword@myhost:6379/1'
})

redis = schedulers.get_redis(app)
conf = schedulers.RedBeatConfig(app)
keys = redis.zrange(conf.schedule_key, 0, -1)
entries = [schedulers.RedBeatSchedulerEntry.from_key(key, app=app)
           for key in keys]
pprint(entries)

@gduverger
Copy link
Author

It works! I'm assuming there is a more built-in way to do it but I can't figure it out. Maybe others will know. In the meantime, thank you, @tlinhart. 🙏

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