Skip to content

Commit 26b0d02

Browse files
committed
Updates per feedback
1 parent 7a8f86c commit 26b0d02

File tree

9 files changed

+33
-25
lines changed

9 files changed

+33
-25
lines changed

src/content/docs/workers/languages/python/basics.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,21 @@ and compatibility_flags in your config file.
149149

150150
## Upgrading `pywrangler`
151151

152-
To upgrade to the latest version of `pywrangler`, run the following command:
152+
To upgrade to the latest version of `pywrangler` globally, run the following command:
153153

154154
```bash
155155
uv tool upgrade workers-py
156156
```
157157

158+
To upgrade to the latest version of `pywrangler` in a specific project, run the following command:
159+
160+
```bash
161+
uv lock --upgrade-package workers-py
162+
```
163+
158164
## Next Up
159165

160-
- Learn details about local development, deployment, and [how to Python Workers work](/workers/languages/python/how-python-workers-work).
166+
- Learn details about local development, deployment, and [how Python Workers work](/workers/languages/python/how-python-workers-work).
161167
- Explore the [package](/workers/languages/python/packages) docs for instructions on how to use packages with Python Workers.
162168
- Understand which parts of the [Python Standard Library](/workers/languages/python/stdlib) are supported in Python Workers.
163169
- Learn about Python Workers' [foreign function interface (FFI)](/workers/languages/python/ffi), and how to use it to work with [bindings](/workers/runtime-apis/bindings) and [Runtime APIs](/workers/runtime-apis/).

src/content/docs/workers/languages/python/examples.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class List(DurableObject):
160160
await self.ctx.storage.put("messages", to_js(messages))
161161
return
162162

163-
async def say_hello(self):
163+
async def say_hello(self):
164164
result = self.ctx.storage.sql.exec(
165165
"SELECT 'Hello, World!' as greeting"
166166
).one()
@@ -180,7 +180,7 @@ class Default(WorkerEntrypoint):
180180
print("cron processed")
181181
```
182182

183-
Refer to [Cron Triggers documentation](/workers/configuration/cron-triggers/) for more information.
183+
Refer to [Cron Triggers documentation](/workers/configuration/cron-triggers/) for more information.
184184

185185
## Workflows
186186

src/content/docs/workers/languages/python/ffi.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Under the hood, `env` is actually a JavaScript object. When you call `.FOO`, you
5252

5353
### Converting Python to JavaScript
5454

55-
Occasionally, to interoperate with JavaScript APIs, you may need to convert a Python objebect to JavaScript. Pyodide provides a `to_js` function to facilitate this conversion.
55+
Occasionally, to interoperate with JavaScript APIs, you may need to convert a Python object to JavaScript. Pyodide provides a `to_js` function to facilitate this conversion.
5656

5757
````python
5858
from js import Object
@@ -66,6 +66,8 @@ def to_js(obj):
6666
```
6767
````
6868

69+
For more details, see out the [documentation on `pyodide.ffi.to_js`](https://pyodide.org/en/stable/usage/api/python-api/ffi.html#pyodide.ffi.to_js).
70+
6971
## Using JavaScript globals from Python Workers
7072

7173
When writing Workers in Python, you can access JavaScript globals by importing them from the `js` module. For example, note how `Response` is imported from `js` in the example below:

src/content/docs/workers/languages/python/how-python-workers-work.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ When you write a Python Worker, your code is interpreted directly by Pyodide, wi
1616

1717
## Local Development
1818

19-
A basic Python Worker includes a Python file with an `Default` class extending `WorkerEntrypoint`, such as:
19+
A basic Python Worker includes a Python file with a `Default` class extending `WorkerEntrypoint`, such as:
2020

2121
```python
2222
from workers import Response, WorkerEntrypoint

src/content/docs/workers/languages/python/index.mdx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { WranglerConfig } from "~/components";
1515

1616
Cloudflare Workers provides a first-class Python experience, including support for:
1717

18-
- The majority of Python's [Standard library](/workers/languages/python/stdlib/)
1918
- Easy to install and fast-booting [Packages](/workers/languages/python/packages), including [FastAPI](https://fastapi.tiangolo.com/), [Langchain](https://pypi.org/project/langchain/), [httpx](https://www.python-httpx.org/), [Pydantic](https://docs.pydantic.dev/latest/) and more.
2019
- A robust [foreign function interface (FFI)](/workers/languages/python/ffi) that lets you use JavaScript objects and functions directly from Python — including all [Runtime APIs](/workers/runtime-apis/)
2120
- An ecosystem of services on the Workers Platform accessible via [bindings](/workers/runtime-apis/bindings/), including:
@@ -25,15 +24,6 @@ Cloudflare Workers provides a first-class Python experience, including support f
2524
- File storage with [R2](/r2)
2625
- [Durable Workflows](/workflows/), [Queues](/queues/), and [ more](/workers/runtime-apis/bindings/)
2726

28-
:::caution[Python Workers are in beta.]
29-
30-
You must add the `python_workers` compatibility flag to your Worker, while Python Workers are in open beta. Packages are supported using the [pywrangler](/workers/languages/python/packages) tool.
31-
32-
We also recommend using the `python_dedicated_snapshot` for improved performance when using packages.
33-
34-
We'd love your feedback. Join the #python-workers channel in the [Cloudflare Developers Discord](https://discord.cloudflare.com/) and let us know what you'd like to see next.
35-
:::
36-
3727
## Introduction
3828

3929
A Python Worker can be as simple as four lines of code:
@@ -51,6 +41,13 @@ sent to the Worker.
5141

5242
In a Python Worker, this handler is placed in a `Default` class that extends the `WorkerEntrypoint` class (which you can import from the `workers` SDK module).
5343

44+
:::caution[Python Workers are in beta.]
45+
46+
You must add the `python_workers` compatibility flag to your Worker, while Python Workers are in open beta. Packages are supported using the [pywrangler](/workers/languages/python/packages) tool.
47+
48+
We'd love your feedback. Join the #python-workers channel in the [Cloudflare Developers Discord](https://discord.cloudflare.com/) and let us know what you'd like to see next.
49+
:::
50+
5451
### The `pywrangler` CLI tool
5552

5653
To run a Python Worker locally, install packages, and deploy it to Cloudflare, you use [pywrangler](https://github.com/cloudflare/workers-py),
@@ -80,7 +77,7 @@ To deploy a Python Worker to Cloudflare, run `pywrangler deploy`:
8077
uv run pywrangler deploy
8178
```
8279

83-
### Python Worker Templaes
80+
### Python Worker Templates
8481

8582
When you initialize a new Python Worker project and select from one of many templates:
8683

src/content/docs/workers/languages/python/packages/fastapi.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Clone the `cloudflare/python-workers-examples` repository and run the FastAPI ex
2121
```bash
2222
git clone https://github.com/cloudflare/python-workers-examples
2323
cd python-workers-examples/03-fastapi
24-
npx wrangler@latest dev
24+
uv run pywrangler dev
2525
```
2626

2727
### Example code

src/content/docs/workers/languages/python/packages/langchain.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Clone the `cloudflare/python-workers-examples` repository and run the LangChain
2323
```bash
2424
git clone https://github.com/cloudflare/python-workers-examples
2525
cd 04-langchain
26-
npx wrangler@latest dev
26+
uv run pywrangler dev
2727
```
2828

2929
### Example code

src/content/docs/workers/runtime-apis/handlers/scheduled.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ from workers import WorkerEntrypoint, Response, fetch
6161

6262
class Default(WorkerEntrypoint):
6363
async def scheduled(self, controller, env, ctx):
64-
ctx.waitUntil(doSomeTaskOnASchedule())
64+
ctx.waitUntil(doSomeTaskOnASchedule())
6565
```
6666

6767
</TabItem></Tabs>
@@ -87,5 +87,9 @@ class Default(WorkerEntrypoint):
8787

8888
When a Workers script is invoked by a [Cron Trigger](/workers/configuration/cron-triggers/), the Workers runtime starts a `ScheduledEvent` which will be handled by the `scheduled` function in your Workers Module class. The `ctx` argument represents the context your function runs in, and contains the following methods to control what happens next:
8989

90-
- <code>ctx.waitUntil(promisePromise)</code> : void
91-
- Use this method to notify the runtime to wait for asynchronous tasks (for example, logging, analytics to third-party services, streaming and caching). The first `ctx.waitUntil` to fail will be observed and recorded as the status in the [Cron Trigger](/workers/configuration/cron-triggers/) Past Events table. Otherwise, it will be reported as a success.
90+
- <code>ctx.waitUntil(promisePromise)</code> : void - Use this method to notify
91+
the runtime to wait for asynchronous tasks (for example, logging, analytics to
92+
third-party services, streaming and caching). The first `ctx.waitUntil` to
93+
fail will be observed and recorded as the status in the [Cron
94+
Trigger](/workers/configuration/cron-triggers/) Past Events table. Otherwise,
95+
it will be reported as a success.

src/content/docs/workflows/python/bindings.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ The `create` method returns a [`WorkflowInstance`](/workflows/build/workers-api/
9393

9494
Create (trigger) a batch of new workflow instances, up to 100 instances at a time. This is useful if you need to create multiple instances at once within the [instance creation limit](/workflows/reference/limits/).
9595

96-
- <code>create_batch(batch)</code>* `batch` - list of
97-
`WorkflowInstanceCreateOptions` to pass when creating an instance, including a
98-
user-provided ID and payload parameters.
96+
* <code>create_batch(batch)</code>
97+
* `batch` - list of `WorkflowInstanceCreateOptions` to pass when creating an instance, including a user-provided ID and payload parameters.
9998

10099
Each element of the `batch` list is expected to include both `id` and `params` properties:
101100

0 commit comments

Comments
 (0)