Skip to content

Example given for scheduled handler in python have positional arguments that are None. #30383

@SuzukiRyuichiro

Description

@SuzukiRyuichiro

Existing documentation URL(s)

In this section, the scheduled method takes 4 positional arguments. However, in reality, env and ctx are both None, and other doc (although this is for fetch) suggested that I should access the context and environment variables via self.ctx and self.env, which does work.

What changes are you suggesting?

I believe this example needs to be modified, including the section below where it generally describes what each arguments are. However, they are written in a manner that is programming language agnostic, so there needs to be clarification for the pythons case that those values are available under self and not positional arguments.

I think example could be something similar to this example in cloudflare/python-worker-examples repo

However, this example is faulty as scheduled still receiving four positional arguments, which I wonder if it is bug.

Additional information

If I run the given example in the cloudflare/python-worker-examples repo, it would throw this error saying wrong number of arguments.

Image

if you run a code that is similar to the code block I raised a ticket about, both ctx and env are None

from workers import WorkerEntrypoint

class Default(WorkerEntrypoint):
    async def scheduled(self, controller, env, ctx):
        print(env, ctx)

The above code yields the below

Image

Metadata

Metadata

Labels

content:editRequest for content editsdocumentationDocumentation editsproduct:workersRelated to Workers productproduct:workflowsWorkflows: https://developers.cloudflare.com/workflows/

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions