qcc_kplugin.qcache

Cache and background loading of the slow qcc components … queries (list, parameters, outline).

Each call starts Python and imports the library (~1.4 s). Called synchronously from the panel that froze KLayout, so:

  • results are cached in memory and in one JSON file in the temp folder (so the next KLayout start is instant too);

  • the cache is valid for one library key: the qcc path and time, and the newest modification time under src/quantcore_circuits/layouts when the plugin runs from the repository. A library change refreshes everything;

  • fetch() runs a query in a subprocess polled from a timer and calls done(data) when it is there, at once when the result is cached. data is None when qcc failed.

Names used by the panel: list:<source>, schema:<cell>, outline:<cell>:<params JSON>, plus the bulk schemas:quantcore that fills every schema:<cell> in one call (prefetch).

Attributes

Functions

clear() → None

Forget everything (the panel's Refresh list).

fetch(name, args[, done, bulk]) → None

done(data) with the JSON of qcc *args — at once when name is cached, else after the background run.

get(name)

The cached value of name (None when absent or from another library version).

library_key() → str

qcc path + its mtime + newest mtime of the library sources (re-evaluated at most every 2 s).

loads_tolerant(text)

json.loads for what a qcc call printed. Some Quantum Metal calls print a warning line on stdout before the

outline_key(cell, params_json) → str

poll() → bool

Collect the finished queries and call their callbacks; True while something still runs.

put(name, value[, save]) → None

schema_key(cell) → str

wait([timeout]) → None

Block until nothing is pending (tests only).

Module Contents

qcc_kplugin.qcache.clear() → None

Forget everything (the panel’s Refresh list).

qcc_kplugin.qcache.fetch(name: str, args: list[str], done=None, bulk: bool = False) → None

done(data) with the JSON of qcc *args — at once when name is cached, else after the background run.

qcc_kplugin.qcache.get(name: str)

The cached value of name (None when absent or from another library version).

qcc_kplugin.qcache.library_key() → str

qcc path + its mtime + newest mtime of the library sources (re-evaluated at most every 2 s).

qcc_kplugin.qcache.loads_tolerant(text: str)

json.loads for what a qcc call printed. Some Quantum Metal calls print a warning line on stdout before the JSON (FutureWarning: ...): then the JSON is the last line that starts with { or [.

qcc_kplugin.qcache.outline_key(cell: str, params_json: str) → str
qcc_kplugin.qcache.poll() → bool

Collect the finished queries and call their callbacks; True while something still runs.

qcc_kplugin.qcache.put(name: str, value, save: bool = True) → None
qcc_kplugin.qcache.schema_key(cell: str) → str
qcc_kplugin.qcache.wait(timeout: float = 60.0) → None

Block until nothing is pending (tests only).

qcc_kplugin.qcache.CACHE_FILE
qcc_kplugin.qcache.LAYOUTS
qcc_kplugin.qcache.PENDING: dict[str, dict]