Skip to content

Provider resource table

Some results outlive the call that produced them: a loaded model, an open connection, an iterator. The object stays in the provider process, and the provider resource table is its single owner there. The table gives each held object a provider-local id, and that id is a name inside one provider epoch. The handle a caller eventually holds is minted by the nucleus. This page covers the table, the path from a Python object to a kernel handle, and the properties the table guarantees.

From object to handle

flowchart TB
  subgraph PROV["CPYTHON PROVIDER, UNTRUSTED"]
    direction TB
    OBJ["Live Python object"]
    TAB[("Resource table<br/>provider-local id, provider epoch")]
    PROP["Typed resource or stream proposal<br/>interface id, resource ordinal"]
    OBJ --> TAB --> PROP
  end
  subgraph MONBOX["CELL MONITOR, TRUSTED"]
    direction TB
    VAL{{"Validates the proposal"}}
    SLOT[("Owner-local resource slot")]
    VAL --> SLOT
  end
  subgraph NUC["NUCLEUS"]
    direction TB
    AUTH{{"Authorises"}}
    H["Caller-visible kernel handle"]
    AUTH --> H
  end
  PROP --> VAL
  SLOT --> AUTH

Promotion has four stages with four owners: the provider proposes, the owner monitor validates, the nucleus authorises, and the handle is installed for the caller. Live Python object and Resource table are the provider's whole part. See Handle import and export and Handle authority.

What a proposal names

A proposal names the resource type by the admitted interface id and the resource ordinal. The Python class name plays no part, so the set of resource types a block can offer is the set its sealed interface declares.

Table properties

  • Ids are monotonic within one provider epoch. An id identifies one object for the life of that provider process.
  • Ids are never reused. A released id stays released.
  • Lookup is epoch-fenced. An id presented with another provider epoch is refused.
  • Release is idempotent. Releasing a released id succeeds.
  • Shutdown drains the table. Cooperative shutdown releases every held object before the provider reports its release fact.

A provider restart starts a new epoch with an empty table. Ids from the earlier process name nothing in the new one. The table holds objects and ids only: grants, kernel handles, scheduling and policy are held by the monitor and the nucleus.