Durable Objects now supported in Python Workers
You can now create Durable Objects using Python Workers, combining compute with storage to enable stateful long-running applications. Define Durable Objects in Python similarly to JavaScript and configure them in your Wrangler configuration file.
You can now create Durable Objects using Python Workers. A Durable Object is a special kind of Cloudflare Worker which uniquely combines compute with storage, enabling stateful long-running applications which run close to your users. For more info see here.
You can define a Durable Object in Python in a similar way to JavaScript:
from workers import DurableObject, Response, WorkerEntrypoint
from urllib.parse import urlparse
class MyDurableObject(DurableObject):
def __init__(self, ctx, env):
self.ctx = ctx
self.env = env
def fetch(self, request):
result = self.ctx.storage.sql.exec("SELECT 'Hello, World!' as greeting").one()
return Response(result.greeting)
class Default(WorkerEntrypoint):
async def fetch(self, request):
url = urlparse(request.url)
id = env.MY_DURABLE_OBJECT.idFromName(url.path)
stub = env.MY_DURABLE_OBJECT.get(id)
greeting = await stub.fetch(request.url)
return greeting
Define the Durable Object in your Wrangler configuration file:
{
"durable_objects": {
"bindings": [
{
"name": "MY_DURABLE_OBJECT",
"class_name": "MyDurableObject"
}
]
}
}[[durable_objects.bindings]]
name = "MY_DURABLE_OBJECT"
class_name = "MyDurableObject"
Then define the storage backend for your Durable Object:
{
"migrations": [
{
"tag": "v1", // Should be unique for each entry
"new_sqlite_classes": [ // Array of new classes
"MyDurableObject"
]
}
]
}[[migrations]]
tag = "v1"
new_sqlite_classes = [ "MyDurableObject" ]
Then test your new Durable Object locally by running wrangler dev:
npx wrangler dev
Consult the Durable Objects documentation for more details.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare One Client for macOS 2026.8.2100.0
GA release for macOS Cloudflare One Client with improved split tunnel handling that no longer briefly blocks traffic during reconnects, support for non-RFC 1918 local IPv4 networks, faster connects with lower memory use, and numerous reliability fixes across DNS, reauthentication, and client stability.
Cloudflare One Client for Windows 2026.8.2100.0
This GA release improves split tunnel reliability, adds support for non-RFC 1918 local networks, optimizes connection performance with faster reconnections and lower memory usage, and includes numerous bug fixes for DNS, registration, and network handling. The client now features a service recovery mechanism that automatically restarts on system unlock and better handles large hosts files without blocking traffic.
Cloudflare One Client for Linux 2026.8.2100.0
New GA release for Linux with improved split tunnel handling that no longer briefly blocks traffic during reconnects, support for non-RFC 1918 local IPv4 networks, faster tunnel reconnections, and lower memory usage. Includes numerous stability and reliability fixes for DNS, reconnection behavior, and crash issues.