Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
7e3cbc67
Commit
7e3cbc67
authored
1 year ago
by
Mohammad Torkashvand
Browse files
Options
Downloads
Patches
Plain Diff
pass doc linter
parent
fe8a775f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!101
Added celery worker and celery beat
Pipeline
#84462
passed
1 year ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/schedules/scheduling.py
+12
-75
12 additions, 75 deletions
gso/schedules/scheduling.py
with
12 additions
and
75 deletions
gso/schedules/scheduling.py
+
12
−
75
View file @
7e3cbc67
...
...
@@ -14,81 +14,18 @@ def scheduler(
day_of_month
:
str
=
"
*
"
,
month_of_year
:
str
=
"
*
"
,
)
->
Callable
[[
Callable
],
Callable
]:
"""
Crontab schedule.
A Crontab can be used as the ``run_every`` value of a
periodic task entry to add :manpage:`crontab(5)`-like scheduling.
Like a :manpage:`cron(5)`-job, you can specify units of time of when
you
'
d like the task to execute. It
'
s a reasonably complete
implementation of :command:`cron`
'
s features, so it should provide a fair
degree of scheduling needs.
You can specify a minute, an hour, a day of the week, a day of the
month, and/or a month in the year in any of the following formats:
.. attribute:: minute
- A (list of) integers from 0-59 that represent the minutes of
an hour of when execution should occur; or
- A string representing a Crontab pattern. This may get pretty
advanced, like ``minute=
'
*/15
'
`` (for every quarter) or
``minute=
'
1,13,30-45,50-59/2
'
``.
.. attribute:: hour
- A (list of) integers from 0-23 that represent the hours of
a day of when execution should occur; or
- A string representing a Crontab pattern. This may get pretty
advanced, like ``hour=
'
*/3
'
`` (for every three hours) or
``hour=
'
0,8-17/2
'
`` (at midnight, and every two hours during
office hours).
.. attribute:: day_of_week
- A (list of) integers from 0-6, where Sunday = 0 and Saturday =
6, that represent the days of a week that execution should
occur.
- A string representing a Crontab pattern. This may get pretty
advanced, like ``day_of_week=
'
mon-fri
'
`` (for weekdays only).
(Beware that ``day_of_week=
'
*/2
'
`` does not literally mean
'
every two days
'
, but
'
every day that is divisible by two
'
!)
.. attribute:: day_of_month
- A (list of) integers from 1-31 that represents the days of the
month that execution should occur.
- A string representing a Crontab pattern. This may get pretty
advanced, such as ``day_of_month=
'
2-30/2
'
`` (for every even
numbered day) or ``day_of_month=
'
1-7,15-21
'
`` (for the first and
third weeks of the month).
.. attribute:: month_of_year
- A (list of) integers from 1-12 that represents the months of
the year during which execution can occur.
- A string representing a Crontab pattern. This may get pretty
advanced, such as ``month_of_year=
'
*/3
'
`` (for the first month
of every quarter) or ``month_of_year=
'
2-12/2
'
`` (for every even
numbered month).
.. attribute:: nowfun
Function returning the current date and time
(:class:`~datetime.datetime`).
.. attribute:: app
The Celery app instance.
It
'
s important to realize that any day on which execution should
occur must be represented by entries in all three of the day and
month attributes. For example, if ``day_of_week`` is 0 and
``day_of_month`` is every seventh day, only months that begin
on Sunday and are also in the ``month_of_year`` attribute will have
execution events. Or, ``day_of_week`` is 1 and ``day_of_month``
is
'
1-7,15-21
'
means every first and third Monday of every month
present in ``month_of_year``.
"""
Schedule a Celery task using crontab-like timing.
Examples
--------
- `minute=
'
*/15
'
`: Run every 15 minutes.
- `hour=
'
*/3
'
`: Run every 3 hours.
- `day_of_week=
'
mon-fri
'
`: Run on weekdays only.
- `day_of_month=
'
1-7,15-21
'
`: Run on the first and third weeks of the month.
- `month_of_year=
'
*/3
'
`: Run on the first month of each quarter.
All time units can be specified with lists of numbers or crontab pattern strings for advanced scheduling.
All specified time parts (minute, hour, day, etc.) must align for a task to run.
"""
def
decorator
(
task_func
:
Callable
)
->
Callable
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment