-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Python workers: Replace remaining examples with on_fetch with WorkerEntrypoint class #25794
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
Python workers: Replace remaining examples with on_fetch with WorkerEntrypoint class #25794
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
cloudflare-docs-e2e | b30242a | Oct 13 2025, 03:02 PM |
b30242a to
52519e7
Compare
|
Hey there, we've marked this pull request as stale because there's no recent activity on it. This label is helps us identify PRs that might need updates (or to be closed out by our team if no longer relevant). |
| class Default(WorkerEntrypoint): | ||
| async def fetch(self, request): | ||
| event = {"foo": "bar"} | ||
| options = to_js({"params": event}, dict_converter=Object.fromEntries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this is correct at the moment. But since we recently started wrapping the binding in the workers module, we can do this internally (with a compat flag)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it would be good to do that, we plan to do this for all bindings eventually
|
We probably need to bump the compatibility date on the docs, right? We should have it set according to the |
| async def on_fetch(request, env): | ||
| await env.MY_WORKFLOW.create() | ||
| return Response("Hello Workflow creation!") | ||
| class Default(WorkerEntrypoint): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to import WorkerEntrypoint as well
Updating Python workers examples