Python Workers 正式 GA 了。2026 年 9 月 21 日,Cloudflare 结束了长达两年的预览期,宣布 Python 成为 Workers 平台的一等公民[1][2]。
🚀 核心能力:你熟悉的 Python 都能跑
这次 GA 最大的变化是 “不逼你重写代码”。以前想跑 Python 得迁就平台,现在是平台来适配你的习惯[1][3]。
- Web 框架直接跑:FastAPI、Django、Flask 都能用。Cloudflare 提供了
workers.asgi和workers.wsgi连接器,把进来的请求转换成框架认识的格式。你不需要在 Worker 里再跑 Uvicorn 或 Gunicorn,Workers 平台本身就是那个“服务器”[1][4]。 - 能连数据库了:这是之前最大的痛点。Python 的数据库驱动依赖 TCP Socket,而 WebAssembly 沙箱里没有。Cloudflare 直接实现了 Socket 系统调用,让
asyncpg、aiomysql这些驱动能直接连 PostgreSQL 和 MySQL(通过 Hyperdrive 集成)[1][3]。 - AI 生态铺好了:
openai、LangChain这些库也能在 Worker 里跑。Cloudflare 甚至向上游贡献了修复,让这些库在 WASM 环境里自动走 Workers 的fetchAPI[5][3]。
⚙️ 它是怎么跑起来的
底层是 Pyodide(CPython 编译成 WebAssembly) 跑在 V8 isolate 里。为了压住 Python 的启动开销,Cloudflare 用了 WASM 内存快照:部署时预先加载常用依赖并拍快照,请求进来直接恢复,冷启动大约在 1 秒,比 AWS Lambda 快一个量级(官方数据是比 Lambda 快 2.4 倍)[6][7][8]。
⚠️ 甜点与“坑”
甜点很甜:边缘就近执行(300+ 城市)、免流量费、免费额度 10 万次/天、直接调用 Workers AI(env.AI.run())做 RAG 或分类[7][9]。
坑也是真硬:
- C 扩展是道坎:带 C/C++/Rust 扩展的包(如
polars、duckdb)不能直接跑,需要等 PyEmscripten 编译版本。这也是 PEP 783 要解决的事——标准化 WASM 包的发布格式[1][7]。 - WASM 沙箱的限制:
multiprocessing和threading基本不可用;本地文件系统是临时的,持久化数据得放 R2/KV/D1[2][5]。 - 启动税:即使热状态,Python Worker 的启动也比纯 TS Worker 慢。Kent C. Dodds 实测后认为“即使热启动也慢很多,且没解锁新能力”,决定暂不迁移[10]。
💡 对你意味着什么
结合你构建的 PAOS 体系,这件事值得看一眼的点在于:Cloudflare 生态里的“薄包装”又多了一种语言选择。
你目前的轻量 API 层、以及各种小工具,基本都是 JS/TS Worker。Python Workers GA 之后,如果你有一些已有的 Python 脚本(比如数据处理、AI pipeline、或者与系统相关的轻量逻辑),理论上可以不重写、直接扔到 Worker 上跑,而且离你的用户更近。
但“能不能跑”和“该不该跑”是两回事。对于克制架构的偏好,Python Worker 的启动税和 WASM 沙箱限制,意味着它更适合事件驱动、低频、逻辑相对独立的任务,而不是盲目替换现有的轻量 JS Worker。
它真正的价值在于“解锁”:以前因为语言限制没法放到边缘的 Python 逻辑,现在多了一个选项。
- [1]
- [2]
- [11]
参考来源
[1] Python Workers are now generally available — https://blog.cloudflare.com/python-workers-ga/?utm_campaign=cf_blog&utm_content=20260921&utm_medium=organic_social&utm_source=linkedin
[2] Cloudflare Python Workers are now generally available — https://simonwillison.net/2026/Sep/21/cloudflare-python-worker/
[3] Cloudflare Python Workers GA: FastAPI & Hyperdrive (2026) | explainx.ai Blog — https://www.explainx.ai/blog/cloudflare-python-workers-ga-quick-tunnels-2026
[4] Python Workers are now generally available — https://blog.cloudflare.com/python-workers-ga/?featured_on=pythonbytes
[5] Cloudflare Python Workers exit beta with direct platform access – 4sysops — https://4sysops.com/archives/cloudflare-python-workers-exit-beta-with-direct-platform-access/
[6] Python Workers Redux:快速冷启动、软件包和 uv 优先的工作流程 — https://blog.cloudflare.com/zh-cn/python-workers-advancements/#cookie-settings
[7] Cloudflare Python Workers 终于 GA:把 Python 塞进 WebAssembly 扔到全球边缘,我看到的甜点与坑 — https://www.cnblogs.com/funkygod/p/23096570
[8] Python Workers Guide: Cloudflare Edge & RQ Background Tasks — https://www.sourcetrail.com/python/mastering-python-workers-from-serverless-edge-to-background-queues/
[9] Python Workers Redux:快速冷啟動、套件以及 uv 優先工作流程 — https://blog.cloudflare.com/zh-tw/python-workers-advancements/
[10] Cloudflare Python Workers are GA, but the startup tax is real | daily.dev — https://daily.dev/posts/cloudflare-python-workers-are-ga-but-the-startup-tax-is-real-h5uc0vknh
[11] Cloudflare Python Workers Redux — https://blog.cloudflare.com/zh-cn/python-workers-advancements/