Skip to content

Workers: add cron trigger changelog and docs for Python Workers. #21875

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

Merged
merged 2 commits into from
Apr 23, 2025

Conversation

dom96
Copy link
Contributor

@dom96 dom96 commented Apr 22, 2025

Summary

Cron triggers have been recently fixed in Python Workers so let's announce them in our docs and changelog.

Note that Python Workers need to be triggered differently when testing locally. The /__scheduled endpoint doesn't work because it relies on wrangler injecting some JavaScript code which is not possible for Python Workers. I spoke with @penalosa about this and it seems the long-term plan is to move to the /cdn-cgi/handler/scheduled handler eventually anyway, so we may as well point Python Workers devs to it.

Documentation checklist

Copy link
Contributor

hyperlint-ai bot commented Apr 22, 2025

Howdy and thanks for contributing to our repo. The Cloudflare team reviews new, external PRs within two (2) weeks. If it's been two weeks or longer without any movement, please tag the PR Assignees in a comment.

We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally.


PR Change Summary

Announced the support for cron triggers in Python Workers, enhancing the documentation and changelog accordingly.

  • Added a new changelog entry for cron triggers in Python Workers.
  • Updated documentation to include Python examples for cron triggers.
  • Modified existing documentation to clarify testing procedures for Python Workers.

Modified Files

  • src/content/docs/workers/configuration/cron-triggers.mdx
  • src/content/docs/workers/examples/cron-trigger.mdx
  • src/content/docs/workers/examples/multiple-cron-triggers.mdx
  • src/content/docs/workers/runtime-apis/fetch.mdx
  • src/content/docs/workers/runtime-apis/handlers/scheduled.mdx
  • src/content/docs/workers/wrangler/commands.mdx

Added Files

  • src/content/changelog/workers/2025-04-22-python-worker-cron-triggers.mdx

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@dom96 dom96 force-pushed the dominik/python-scheduled-worker branch 2 times, most recently from 7e05207 to 18095d4 Compare April 22, 2025 10:42
@@ -27,7 +27,42 @@ Cron Triggers execute on UTC time.

To respond to a Cron Trigger, you must add a [`"scheduled"` handler](/workers/runtime-apis/handlers/scheduled/) to your Worker.

<Render file="cron-trigger-example" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the repercussions of this change are but I seem to recall that we intentionally wanted to move away from inlined examples in the docs to allow testing them properly in case they suddenly break.
Maybe someone with more docs experience can chime in.

@dom96 dom96 force-pushed the dominik/python-scheduled-worker branch 2 times, most recently from f518bea to 36e2735 Compare April 22, 2025 11:24
Copy link
Contributor

github-actions bot commented Apr 22, 2025

@dom96 dom96 force-pushed the dominik/python-scheduled-worker branch from 36e2735 to a300f2a Compare April 22, 2025 12:56
@dom96 dom96 enabled auto-merge (squash) April 23, 2025 11:15
Copy link
Contributor

@mikenomitch mikenomitch left a comment

Choose a reason for hiding this comment

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

LGTM - left one ignorable suggestion


You can now create Python Workers which are executed via a cron trigger.

This is similar to how it's done in JavaScript workers, simply define a scheduled event
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional - you can link here to remind people of the JS API

@dom96 dom96 disabled auto-merge April 23, 2025 16:21
Co-authored-by: ToriLindsay <[email protected]>
@dom96 dom96 enabled auto-merge (squash) April 23, 2025 17:32
@dom96 dom96 merged commit a90aade into production Apr 23, 2025
13 checks passed
@dom96 dom96 deleted the dominik/python-scheduled-worker branch April 23, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:workers Related to Workers product size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.