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

Add support for job scheduling #26

Merged
merged 2 commits into from
May 10, 2019
Merged

Add support for job scheduling #26

merged 2 commits into from
May 10, 2019

Conversation

sdispater
Copy link

This PR adds two new configuration option for jobs: schedule_at and schedule_in.

  • schedule_at must be a timezone-aware datetime representing the moment the job must be executed.
  • schedule_in must be a dictionnary representing the relative time the job must be executed at
import pendulum
from cabbage import TaskManager

manager = TaskManager()


@manager.task(queue="default")
def add(a, b):
    return a + b

add.configure(schedule_at=pendulum.now().add(minutes=2)).defer(a=1, b=2)
add.configure(schedule_in={"minutes": 2}).defer(a=1, b=2)

@@ -23,6 +23,7 @@ packages = find:
install_requires =
psycopg2
attrs
pendulum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the setup.cfg file.

And regarding type annotations, there is a PR (python-pendulum/pendulum#320) that I need to merge at some point.

@codecov-io
Copy link

codecov-io commented May 6, 2019

Codecov Report

Merging #26 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #26   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          10     10           
  Lines         292    309   +17     
  Branches       12     17    +5     
=====================================
+ Hits          292    309   +17
Impacted Files Coverage Δ
cabbage/postgres.py 100% <ø> (ø) ⬆️
cabbage/tasks.py 100% <100%> (ø) ⬆️
cabbage/jobs.py 100% <100%> (ø) ⬆️
cabbage/testing.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1b6103...7c77675. Read the comment docs.

@sdispater sdispater merged commit 298a5f9 into master May 10, 2019
@sdispater sdispater deleted the scheduling branch May 10, 2019 13:30
@ewjoachim ewjoachim mentioned this pull request Aug 2, 2019
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

Successfully merging this pull request may close these issues.

3 participants