Skip to content

Commit

Permalink
Clarify Python scheduled function requirements (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuck-dbos authored Mar 7, 2025
1 parent 00cb106 commit 4c1ec6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/python/reference/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ DBOS.scheduled(

Run a function on a schedule specified using [crontab](https://en.wikipedia.org/wiki/Cron) syntax. See [here](https://docs.gitlab.com/ee/topics/cron/) for a guide to cron syntax and [here](https://crontab.guru/) for a crontab editor.

The annotated function must take in two parameters: The time that the run was scheduled (as a `datetime`) and the time that the run was actually started (also a `datetime`).
The annotated function must take in two parameters: The time that the run was scheduled (as a `datetime`) and the time that the run was actually started (also a `datetime`). Functions within classes may be marked as `@staticmethod` to meet this requirement.

**Example:**
```python
Expand Down
2 changes: 1 addition & 1 deletion docs/python/tutorials/scheduled-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def example_scheduled_workflow(scheduled_time: datetime, actual_time: datetime):
DBOS.logger.info("I am a workflow scheduled to run once a minute. ")
```

Scheduled workflows must take in exactly two arguments: the time that the run was scheduled (as a `datetime`) and the time the run was actually started (as a `datetime`).
Scheduled workflows must take in exactly two arguments: the time that the run was scheduled (as a `datetime`) and the time the run was actually started (as a `datetime`). Note that this means scheduled workflows should either be plain functions, or be `@staticmethod` class members.

To learn more about crontab syntax, see [this guide](https://docs.gitlab.com/ee/topics/cron/) or [this crontab editor](https://crontab.guru/). DBOS uses [croniter](https://pypi.org/project/croniter/) to parse cron schedules, which is able to do second repetition and by default we use seconds as the first field.
The specification for the DBOS variant can be found in the [decorator reference](../reference/decorators.md#scheduled).
Expand Down

0 comments on commit 4c1ec6e

Please sign in to comment.