CloudflareHood ChathamAnnouncement
Python Workers are now generally available
Summary
Cloudflare announced general availability of Python Workers, making Python a first-class language on its developer platform. The runtime now encapsulates type conversion so developers use Cloudflare bindings like D1 and Workers AI directly, without the previously required JavaScript glue code. Popular frameworks FastAPI, Django, and Flask run inside Workers via built-in ASGI and WSCI connectors that translate JavaScript requests into standard Python structures. A custom socket syscall implementation enables TCP connections for database drivers, unlocking Hyperdrive integration with PostgreSQL and MySQL, previously blocked by WebAssembly sandbox limits. Example projects include streaming from Bluesky Jetstream via Durable Objects, building an MCP server with the official Python MCP package, and creating a RAG system with Vectorize, with documentation now including Python examples alongside TypeScript.
Context
Cloudflare Workers have supported WebAssembly since 2018, providing an environment to run a Wasm-compiled Python interpreter via Podide. After a multi-year effort, Python Workers are now production-ready with native support for all Cloudflare Developer Platform bindings, popular web frameworks, and TCP-based database drivers.
Approach / What changed
Cloudflare used Pyodide to run a Wasm-compiled Python interpreter in the Workers runtime. They encapsulated the type conversion process between Python and JavaScript within the runtime and Python SDK, eliminating the need for glue code. They built workers.asgi and workers.wsgi connectors that translate JavaScript requests into standard WSCI/ASGI structures, allowing web frameworks to run without a separate server. For TCP support, they implemented socket system calls using the Workers connect API, translating standard Python socket operations into corresponding JavaScript calls at the system call level, enabling database drivers to connect via Hyperdrive.
Takeaways
Python Workers now support all Cloudflare bindings natively without requiring TypeScript conversion glue code
FastAPI, Django, and Flask applications run inside Workers via built-in ASGI and WSGI connectors that eliminat the need for a separate web server
A custom socket syscall implementation enables TCP connections for database drivers, allowing Hyperdrive integration with PostgreSQL and MySQL in Python Workers
FAQ
How do I run a FastAPI app in Python Workers?
Use the workers.asgi package and call asgi.fetch(app, request, self.env) or the shorthand asgi.entrypoint(app). The Workers platform serves as the web server, so no uvicorn is needed; the connector translates JavaScript requests into ASGI structures automatically.
Can I use PostgreSQL with Python Workers?
Yes, via Hyperdrive. The custom socket syscall implementation translates standard Python socket operations into Workers connect API calls, allowing database drivers like aiomysql and asyncpg to work without modification inside the WebAssembly sandbox.
What Python packages are supported?
Python Workers support any pure-Python or Wasm-compatible package. The blog explicitly mentions Podide, FastAPI, Django, Flask, aiomysql, asyncpg, LangChain, and the official Python MCP package, with documentation updated to include Python examples across all products.
Source and freshness
- Source
- blog.cloudflare.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.