Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Update Mongo Schedule entry to support create task dynamically in application still running #66

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dainer88
Copy link

@dainer88 dainer88 commented Jan 14, 2021

With this change package will be used in app like flask.
I added change to return object saved in db after.

Example use
celery.py

from celery import Celery

config = {
    "mongodb_scheduler_db": "my_project",
    "mongodb_scheduler_url": "mongodb://localhost:27017",
}

app = Celery('hello', broker='redis://localhost//')
app.conf.update(**config)

when needed add task in app

from celerybeatmongo.models import PeriodicTask
from celerybeatmongo.schedulers import MongoScheduleEntry

task = PeriodicTask(name= 'Importing contacts', task='proj.import_contacts')
task.crontab = PeriodicTask.Crontab(minute="30", hour="7", day_of_week="1",
                           day_of_month="0", month_of_year="*")

entry = MongoScheduleEntry(task=task, app=app)
entry.save()

For testing purposes only, post this file, which will be available until the release of this version.

@dainer88 dainer88 marked this pull request as ready for review January 14, 2021 04:17
@dainer88
Copy link
Author

@zakird you can review this pull request and release this version.

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

Successfully merging this pull request may close these issues.

1 participant