For scratch state scoped to one script run, use the context managers instead: `with modal.Dict.ephemeral() as d, modal.Queue.ephemeral() as q:` — both are destroyed on exit.
Dict operations: `d.put(key, value, skip_if_exists=False)`, `d.get(key, default)`, `d.pop(key, default)`, `d.contains(key)`, `d.len()`, `d.update(mapping)`, `d.clear()`, and the iterators `d.keys()`, `d.values()`, `d.items()`.
Queue producer side: `q.put(item)` or `q.put_many([...])`. Consumer side: `q.get()` or `q.get_many(n_values, timeout=5)`.
Wrap blocking gets in a try/except: on timeout the SDK raises `queue.Empty` rather than returning None or an empty list.
Pass the Dict/Queue handle into remote work with `some_fn.spawn(q, d, batch)` — the handles are serializable and resolve inside the container.
Use partitions to keep independent streams in one Queue: `q.put(v, partition="tenant-a", partition_ttl=86400)` and `q.get(partition="tenant-a")`. Length and clear are per-partition unless you pass total=True / all=True.
get_many()/get() raise queue.Empty on timeout — code that assumes a falsy return silently spins or crashes.
Dict entries expire after 7 days of inactivity; do not use a Dict as a durable database.
Queue limits: up to 100,000 partitions per Queue, 5,000 items per partition, and 1 MiB per item. Put large payloads in a Volume or object store and enqueue a reference.
Partition keys must be non-empty and at most 64 bytes; partition_ttl defaults to 86400 seconds (24h) and stale partitions vanish.
Values are serialized with cloudpickle — objects that close over unpicklable handles (open sockets, file objects) fail at put time.
Forgetting create_if_missing=True on from_name raises for a not-yet-existing object.
Give your agent this knowledge — and 16,300+ more routes
One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?